Merge pull request #119 from TheBlueMatt/main
[ldk-java] / ts / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include "js-wasm.h"
4 #include <stdatomic.h>
5 #include <lightning.h>
6
7 // These should be provided...somehow...
8 void *memset(void *s, int c, size_t n);
9 void *memcpy(void *dest, const void *src, size_t n);
10 int memcmp(const void *s1, const void *s2, size_t n);
11
12 extern void __attribute__((noreturn)) abort(void);
13 static inline void assert(bool expression) {
14         if (!expression) { abort(); }
15 }
16
17 uint32_t __attribute__((export_name("test_bigint_pass_deadbeef0badf00d"))) test_bigint_pass_deadbeef0badf00d(uint64_t val) {
18         return val == 0xdeadbeef0badf00dULL;
19 }
20
21
22 void *malloc(size_t size);
23 void free(void *ptr);
24
25 #define MALLOC(a, _) malloc(a)
26 #define do_MALLOC(a, _b, _c) malloc(a)
27 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
28 #define DO_ASSERT(a) (void)(a)
29 #define CHECK(a)
30 #define CHECK_ACCESS(p)
31 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
32
33 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
34 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
35 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
36 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
37
38 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
39
40 #define DECL_ARR_TYPE(ty, name) \
41         struct name##array { \
42                 uint64_t arr_len; /* uint32_t would suffice but we want to align uint64_ts as well */ \
43                 ty elems[]; \
44         }; \
45         typedef struct name##array * name##Array; \
46         static inline name##Array init_##name##Array(size_t arr_len, int lineno) { \
47                 name##Array arr = (name##Array)do_MALLOC(arr_len * sizeof(ty) + sizeof(uint64_t), #name" array init", lineno); \
48                 arr->arr_len = arr_len; \
49                 return arr; \
50         }
51
52 DECL_ARR_TYPE(int64_t, int64_t);
53 DECL_ARR_TYPE(uint64_t, uint64_t);
54 DECL_ARR_TYPE(int8_t, int8_t);
55 DECL_ARR_TYPE(uint32_t, uint32_t);
56 DECL_ARR_TYPE(void*, ptr);
57 DECL_ARR_TYPE(char, char);
58 typedef charArray jstring;
59
60 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
61         charArray arr = init_charArray(len, __LINE__);
62         memcpy(arr->elems, chars, len);
63         return arr;
64 }
65 static inline LDKStr str_ref_to_owned_c(const jstring str) {
66         char* newchars = MALLOC(str->arr_len + 1, "String chars");
67         memcpy(newchars, str->elems, str->arr_len);
68         newchars[str->arr_len] = 0;
69         LDKStr res = {
70                 .chars = newchars,
71                 .len = str->arr_len,
72                 .chars_is_owned = true
73         };
74         return res;
75 }
76
77 typedef bool jboolean;
78
79 uint32_t __attribute__((export_name("TS_malloc"))) TS_malloc(uint32_t size) {
80         return (uint32_t)MALLOC(size, "JS-Called malloc");
81 }
82 void __attribute__((export_name("TS_free"))) TS_free(uint32_t ptr) {
83         FREE((void*)ptr);
84 }
85
86 jstring __attribute__((export_name("TS_get_ldk_c_bindings_version"))) TS_get_ldk_c_bindings_version() {
87         const char *res = check_get_ldk_bindings_version();
88         if (res == NULL) return NULL;
89         return str_ref_to_ts(res, strlen(res));
90 }
91 jstring __attribute__((export_name("TS_get_ldk_version"))) get_ldk_version() {
92         const char *res = check_get_ldk_version();
93         if (res == NULL) return NULL;
94         return str_ref_to_ts(res, strlen(res));
95 }
96 #include "version.c"
97 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
98
99 static inline void* untag_ptr(uint64_t ptr) {
100         if (ptr < 4096) return (void*)ptr;
101         if (sizeof(void*) == 4) {
102                 // For 32-bit systems, store pointers as 64-bit ints and use the 31st bit
103                 return (void*)(uintptr_t)ptr;
104         } else {
105                 // For 64-bit systems, assume the top byte is used for tagging, then
106                 // use bit 9 ^ bit 10.
107                 uint64_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
108                 uintptr_t p = (ptr & ~(1ULL << 55)) | (tenth_bit << 55);
109 #ifdef LDK_DEBUG_BUILD
110                 // On debug builds we also use the 11th bit as a debug flag
111                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
112                 CHECK(tenth_bit != eleventh_bit);
113                 p ^= 1ULL << 53;
114 #endif
115                 return (void*)p;
116         }
117 }
118 static inline bool ptr_is_owned(uint64_t ptr) {
119         if(ptr < 4096) return true;
120         if (sizeof(void*) == 4) {
121                 return ptr & (1ULL << 32);
122         } else {
123                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
124                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
125 #ifdef LDK_DEBUG_BUILD
126                 // On debug builds we also use the 11th bit as a debug flag
127                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
128                 CHECK(tenth_bit != eleventh_bit);
129 #endif
130                 return (ninth_bit ^ tenth_bit) ? true : false;
131         }
132 }
133 static inline uint64_t tag_ptr(const void* ptr, bool is_owned) {
134         if ((uintptr_t)ptr < 4096) return (uint64_t)ptr;
135         if (sizeof(void*) == 4) {
136                 return (((uint64_t)ptr) | ((is_owned ? 1ULL : 0) << 32));
137         } else {
138                 CHECK(sizeof(uintptr_t) == 8);
139                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
140                 uintptr_t t = (((uintptr_t)ptr) | (((is_owned ? 1ULL : 0ULL) ^ tenth_bit) << 55));
141 #ifdef LDK_DEBUG_BUILD
142                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
143                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
144                 CHECK(ninth_bit == tenth_bit);
145                 CHECK(ninth_bit == eleventh_bit);
146                 t ^= 1ULL << 53;
147 #endif
148                 CHECK(ptr_is_owned(t) == is_owned);
149                 CHECK(untag_ptr(t) == ptr);
150                 return t;
151         }
152 }
153
154 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
155         switch (ord) {
156                 case 0: return LDKAccessError_UnknownChain;
157                 case 1: return LDKAccessError_UnknownTx;
158         }
159         abort();
160 }
161 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
162         switch (val) {
163                 case LDKAccessError_UnknownChain: return 0;
164                 case LDKAccessError_UnknownTx: return 1;
165                 default: abort();
166         }
167 }
168 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_js(int32_t ord) {
169         switch (ord) {
170                 case 0: return LDKCOption_NoneZ_Some;
171                 case 1: return LDKCOption_NoneZ_None;
172         }
173         abort();
174 }
175 static inline int32_t LDKCOption_NoneZ_to_js(LDKCOption_NoneZ val) {
176         switch (val) {
177                 case LDKCOption_NoneZ_Some: return 0;
178                 case LDKCOption_NoneZ_None: return 1;
179                 default: abort();
180         }
181 }
182 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
183         switch (ord) {
184                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
185                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
186         }
187         abort();
188 }
189 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
190         switch (val) {
191                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
192                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
193                 default: abort();
194         }
195 }
196 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
197         switch (ord) {
198                 case 0: return LDKConfirmationTarget_Background;
199                 case 1: return LDKConfirmationTarget_Normal;
200                 case 2: return LDKConfirmationTarget_HighPriority;
201         }
202         abort();
203 }
204 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
205         switch (val) {
206                 case LDKConfirmationTarget_Background: return 0;
207                 case LDKConfirmationTarget_Normal: return 1;
208                 case LDKConfirmationTarget_HighPriority: return 2;
209                 default: abort();
210         }
211 }
212 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
213         switch (ord) {
214                 case 0: return LDKCreationError_DescriptionTooLong;
215                 case 1: return LDKCreationError_RouteTooLong;
216                 case 2: return LDKCreationError_TimestampOutOfBounds;
217                 case 3: return LDKCreationError_InvalidAmount;
218                 case 4: return LDKCreationError_MissingRouteHints;
219         }
220         abort();
221 }
222 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
223         switch (val) {
224                 case LDKCreationError_DescriptionTooLong: return 0;
225                 case LDKCreationError_RouteTooLong: return 1;
226                 case LDKCreationError_TimestampOutOfBounds: return 2;
227                 case LDKCreationError_InvalidAmount: return 3;
228                 case LDKCreationError_MissingRouteHints: return 4;
229                 default: abort();
230         }
231 }
232 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
233         switch (ord) {
234                 case 0: return LDKCurrency_Bitcoin;
235                 case 1: return LDKCurrency_BitcoinTestnet;
236                 case 2: return LDKCurrency_Regtest;
237                 case 3: return LDKCurrency_Simnet;
238                 case 4: return LDKCurrency_Signet;
239         }
240         abort();
241 }
242 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
243         switch (val) {
244                 case LDKCurrency_Bitcoin: return 0;
245                 case LDKCurrency_BitcoinTestnet: return 1;
246                 case LDKCurrency_Regtest: return 2;
247                 case LDKCurrency_Simnet: return 3;
248                 case LDKCurrency_Signet: return 4;
249                 default: abort();
250         }
251 }
252 static inline LDKIOError LDKIOError_from_js(int32_t ord) {
253         switch (ord) {
254                 case 0: return LDKIOError_NotFound;
255                 case 1: return LDKIOError_PermissionDenied;
256                 case 2: return LDKIOError_ConnectionRefused;
257                 case 3: return LDKIOError_ConnectionReset;
258                 case 4: return LDKIOError_ConnectionAborted;
259                 case 5: return LDKIOError_NotConnected;
260                 case 6: return LDKIOError_AddrInUse;
261                 case 7: return LDKIOError_AddrNotAvailable;
262                 case 8: return LDKIOError_BrokenPipe;
263                 case 9: return LDKIOError_AlreadyExists;
264                 case 10: return LDKIOError_WouldBlock;
265                 case 11: return LDKIOError_InvalidInput;
266                 case 12: return LDKIOError_InvalidData;
267                 case 13: return LDKIOError_TimedOut;
268                 case 14: return LDKIOError_WriteZero;
269                 case 15: return LDKIOError_Interrupted;
270                 case 16: return LDKIOError_Other;
271                 case 17: return LDKIOError_UnexpectedEof;
272         }
273         abort();
274 }
275 static inline int32_t LDKIOError_to_js(LDKIOError val) {
276         switch (val) {
277                 case LDKIOError_NotFound: return 0;
278                 case LDKIOError_PermissionDenied: return 1;
279                 case LDKIOError_ConnectionRefused: return 2;
280                 case LDKIOError_ConnectionReset: return 3;
281                 case LDKIOError_ConnectionAborted: return 4;
282                 case LDKIOError_NotConnected: return 5;
283                 case LDKIOError_AddrInUse: return 6;
284                 case LDKIOError_AddrNotAvailable: return 7;
285                 case LDKIOError_BrokenPipe: return 8;
286                 case LDKIOError_AlreadyExists: return 9;
287                 case LDKIOError_WouldBlock: return 10;
288                 case LDKIOError_InvalidInput: return 11;
289                 case LDKIOError_InvalidData: return 12;
290                 case LDKIOError_TimedOut: return 13;
291                 case LDKIOError_WriteZero: return 14;
292                 case LDKIOError_Interrupted: return 15;
293                 case LDKIOError_Other: return 16;
294                 case LDKIOError_UnexpectedEof: return 17;
295                 default: abort();
296         }
297 }
298 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
299         switch (ord) {
300                 case 0: return LDKLevel_Gossip;
301                 case 1: return LDKLevel_Trace;
302                 case 2: return LDKLevel_Debug;
303                 case 3: return LDKLevel_Info;
304                 case 4: return LDKLevel_Warn;
305                 case 5: return LDKLevel_Error;
306         }
307         abort();
308 }
309 static inline int32_t LDKLevel_to_js(LDKLevel val) {
310         switch (val) {
311                 case LDKLevel_Gossip: return 0;
312                 case LDKLevel_Trace: return 1;
313                 case LDKLevel_Debug: return 2;
314                 case LDKLevel_Info: return 3;
315                 case LDKLevel_Warn: return 4;
316                 case LDKLevel_Error: return 5;
317                 default: abort();
318         }
319 }
320 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
321         switch (ord) {
322                 case 0: return LDKNetwork_Bitcoin;
323                 case 1: return LDKNetwork_Testnet;
324                 case 2: return LDKNetwork_Regtest;
325                 case 3: return LDKNetwork_Signet;
326         }
327         abort();
328 }
329 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
330         switch (val) {
331                 case LDKNetwork_Bitcoin: return 0;
332                 case LDKNetwork_Testnet: return 1;
333                 case LDKNetwork_Regtest: return 2;
334                 case LDKNetwork_Signet: return 3;
335                 default: abort();
336         }
337 }
338 static inline LDKRecipient LDKRecipient_from_js(int32_t ord) {
339         switch (ord) {
340                 case 0: return LDKRecipient_Node;
341                 case 1: return LDKRecipient_PhantomNode;
342         }
343         abort();
344 }
345 static inline int32_t LDKRecipient_to_js(LDKRecipient val) {
346         switch (val) {
347                 case LDKRecipient_Node: return 0;
348                 case LDKRecipient_PhantomNode: return 1;
349                 default: abort();
350         }
351 }
352 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
353         switch (ord) {
354                 case 0: return LDKSecp256k1Error_IncorrectSignature;
355                 case 1: return LDKSecp256k1Error_InvalidMessage;
356                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
357                 case 3: return LDKSecp256k1Error_InvalidSignature;
358                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
359                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
360                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
361                 case 7: return LDKSecp256k1Error_InvalidTweak;
362                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
363                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
364                 case 10: return LDKSecp256k1Error_InvalidParityValue;
365         }
366         abort();
367 }
368 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
369         switch (val) {
370                 case LDKSecp256k1Error_IncorrectSignature: return 0;
371                 case LDKSecp256k1Error_InvalidMessage: return 1;
372                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
373                 case LDKSecp256k1Error_InvalidSignature: return 3;
374                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
375                 case LDKSecp256k1Error_InvalidSharedSecret: return 5;
376                 case LDKSecp256k1Error_InvalidRecoveryId: return 6;
377                 case LDKSecp256k1Error_InvalidTweak: return 7;
378                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
379                 case LDKSecp256k1Error_InvalidPublicKeySum: return 9;
380                 case LDKSecp256k1Error_InvalidParityValue: return 10;
381                 default: abort();
382         }
383 }
384 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
385         switch (ord) {
386                 case 0: return LDKSemanticError_NoPaymentHash;
387                 case 1: return LDKSemanticError_MultiplePaymentHashes;
388                 case 2: return LDKSemanticError_NoDescription;
389                 case 3: return LDKSemanticError_MultipleDescriptions;
390                 case 4: return LDKSemanticError_NoPaymentSecret;
391                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
392                 case 6: return LDKSemanticError_InvalidFeatures;
393                 case 7: return LDKSemanticError_InvalidRecoveryId;
394                 case 8: return LDKSemanticError_InvalidSignature;
395                 case 9: return LDKSemanticError_ImpreciseAmount;
396         }
397         abort();
398 }
399 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
400         switch (val) {
401                 case LDKSemanticError_NoPaymentHash: return 0;
402                 case LDKSemanticError_MultiplePaymentHashes: return 1;
403                 case LDKSemanticError_NoDescription: return 2;
404                 case LDKSemanticError_MultipleDescriptions: return 3;
405                 case LDKSemanticError_NoPaymentSecret: return 4;
406                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
407                 case LDKSemanticError_InvalidFeatures: return 6;
408                 case LDKSemanticError_InvalidRecoveryId: return 7;
409                 case LDKSemanticError_InvalidSignature: return 8;
410                 case LDKSemanticError_ImpreciseAmount: return 9;
411                 default: abort();
412         }
413 }
414 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
415         switch (ord) {
416                 case 0: return LDKSiPrefix_Milli;
417                 case 1: return LDKSiPrefix_Micro;
418                 case 2: return LDKSiPrefix_Nano;
419                 case 3: return LDKSiPrefix_Pico;
420         }
421         abort();
422 }
423 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
424         switch (val) {
425                 case LDKSiPrefix_Milli: return 0;
426                 case LDKSiPrefix_Micro: return 1;
427                 case LDKSiPrefix_Nano: return 2;
428                 case LDKSiPrefix_Pico: return 3;
429                 default: abort();
430         }
431 }
432 struct LDKThirtyTwoBytes BigEndianScalar_get_bytes (struct LDKBigEndianScalar* thing) {
433         LDKThirtyTwoBytes ret = { .data = *thing->big_endian_bytes };
434         return ret;
435 }
436 int8_tArray  __attribute__((export_name("TS_BigEndianScalar_get_bytes"))) TS_BigEndianScalar_get_bytes(uint64_t thing) {
437         LDKBigEndianScalar* thing_conv = (LDKBigEndianScalar*)untag_ptr(thing);
438         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
439         memcpy(ret_arr->elems, BigEndianScalar_get_bytes(thing_conv).data, 32);
440         return ret_arr;
441 }
442
443 static void BigEndianScalar_free (struct LDKBigEndianScalar thing) {}
444 void  __attribute__((export_name("TS_BigEndianScalar_free"))) TS_BigEndianScalar_free(uint64_t thing) {
445         if (!ptr_is_owned(thing)) return;
446         void* thing_ptr = untag_ptr(thing);
447         CHECK_ACCESS(thing_ptr);
448         LDKBigEndianScalar thing_conv = *(LDKBigEndianScalar*)(thing_ptr);
449         FREE(untag_ptr(thing));
450         BigEndianScalar_free(thing_conv);
451 }
452
453 uint32_t __attribute__((export_name("TS_LDKBech32Error_ty_from_ptr"))) TS_LDKBech32Error_ty_from_ptr(uint64_t ptr) {
454         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
455         switch(obj->tag) {
456                 case LDKBech32Error_MissingSeparator: return 0;
457                 case LDKBech32Error_InvalidChecksum: return 1;
458                 case LDKBech32Error_InvalidLength: return 2;
459                 case LDKBech32Error_InvalidChar: return 3;
460                 case LDKBech32Error_InvalidData: return 4;
461                 case LDKBech32Error_InvalidPadding: return 5;
462                 case LDKBech32Error_MixedCase: return 6;
463                 default: abort();
464         }
465 }
466 int32_t __attribute__((export_name("TS_LDKBech32Error_InvalidChar_get_invalid_char"))) TS_LDKBech32Error_InvalidChar_get_invalid_char(uint64_t ptr) {
467         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
468         assert(obj->tag == LDKBech32Error_InvalidChar);
469                         int32_t invalid_char_conv = obj->invalid_char;
470         return invalid_char_conv;
471 }
472 int8_t __attribute__((export_name("TS_LDKBech32Error_InvalidData_get_invalid_data"))) TS_LDKBech32Error_InvalidData_get_invalid_data(uint64_t ptr) {
473         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
474         assert(obj->tag == LDKBech32Error_InvalidData);
475                         int8_t invalid_data_conv = obj->invalid_data;
476         return invalid_data_conv;
477 }
478 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
479         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
480         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
481         return ret;
482 }
483 struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) {   return CVec_u8Z_clone(&thing->script_pubkey);}int8_tArray  __attribute__((export_name("TS_TxOut_get_script_pubkey"))) TS_TxOut_get_script_pubkey(uint64_t thing) {
484         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
485         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
486         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
487         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
488         CVec_u8Z_free(ret_var);
489         return ret_arr;
490 }
491
492 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}int64_t  __attribute__((export_name("TS_TxOut_get_value"))) TS_TxOut_get_value(uint64_t thing) {
493         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
494         int64_t ret_conv = TxOut_get_value(thing_conv);
495         return ret_conv;
496 }
497
498 static inline struct LDKBlindedRoute CResult_BlindedRouteNoneZ_get_ok(LDKCResult_BlindedRouteNoneZ *NONNULL_PTR owner){
499         LDKBlindedRoute ret = *owner->contents.result;
500         ret.is_owned = false;
501         return ret;
502 }
503 uint64_t  __attribute__((export_name("TS_CResult_BlindedRouteNoneZ_get_ok"))) TS_CResult_BlindedRouteNoneZ_get_ok(uint64_t owner) {
504         LDKCResult_BlindedRouteNoneZ* owner_conv = (LDKCResult_BlindedRouteNoneZ*)untag_ptr(owner);
505         LDKBlindedRoute ret_var = CResult_BlindedRouteNoneZ_get_ok(owner_conv);
506         uint64_t ret_ref = 0;
507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
509         return ret_ref;
510 }
511
512 static inline void CResult_BlindedRouteNoneZ_get_err(LDKCResult_BlindedRouteNoneZ *NONNULL_PTR owner){
513 CHECK(!owner->result_ok);
514         return *owner->contents.err;
515 }
516 void  __attribute__((export_name("TS_CResult_BlindedRouteNoneZ_get_err"))) TS_CResult_BlindedRouteNoneZ_get_err(uint64_t owner) {
517         LDKCResult_BlindedRouteNoneZ* owner_conv = (LDKCResult_BlindedRouteNoneZ*)untag_ptr(owner);
518         CResult_BlindedRouteNoneZ_get_err(owner_conv);
519 }
520
521 static inline struct LDKBlindedRoute CResult_BlindedRouteDecodeErrorZ_get_ok(LDKCResult_BlindedRouteDecodeErrorZ *NONNULL_PTR owner){
522         LDKBlindedRoute ret = *owner->contents.result;
523         ret.is_owned = false;
524         return ret;
525 }
526 uint64_t  __attribute__((export_name("TS_CResult_BlindedRouteDecodeErrorZ_get_ok"))) TS_CResult_BlindedRouteDecodeErrorZ_get_ok(uint64_t owner) {
527         LDKCResult_BlindedRouteDecodeErrorZ* owner_conv = (LDKCResult_BlindedRouteDecodeErrorZ*)untag_ptr(owner);
528         LDKBlindedRoute ret_var = CResult_BlindedRouteDecodeErrorZ_get_ok(owner_conv);
529         uint64_t ret_ref = 0;
530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
531         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
532         return ret_ref;
533 }
534
535 static inline struct LDKDecodeError CResult_BlindedRouteDecodeErrorZ_get_err(LDKCResult_BlindedRouteDecodeErrorZ *NONNULL_PTR owner){
536         LDKDecodeError ret = *owner->contents.err;
537         ret.is_owned = false;
538         return ret;
539 }
540 uint64_t  __attribute__((export_name("TS_CResult_BlindedRouteDecodeErrorZ_get_err"))) TS_CResult_BlindedRouteDecodeErrorZ_get_err(uint64_t owner) {
541         LDKCResult_BlindedRouteDecodeErrorZ* owner_conv = (LDKCResult_BlindedRouteDecodeErrorZ*)untag_ptr(owner);
542         LDKDecodeError ret_var = CResult_BlindedRouteDecodeErrorZ_get_err(owner_conv);
543         uint64_t ret_ref = 0;
544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
545         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
546         return ret_ref;
547 }
548
549 static inline struct LDKBlindedHop CResult_BlindedHopDecodeErrorZ_get_ok(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
550         LDKBlindedHop ret = *owner->contents.result;
551         ret.is_owned = false;
552         return ret;
553 }
554 uint64_t  __attribute__((export_name("TS_CResult_BlindedHopDecodeErrorZ_get_ok"))) TS_CResult_BlindedHopDecodeErrorZ_get_ok(uint64_t owner) {
555         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
556         LDKBlindedHop ret_var = CResult_BlindedHopDecodeErrorZ_get_ok(owner_conv);
557         uint64_t ret_ref = 0;
558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
559         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
560         return ret_ref;
561 }
562
563 static inline struct LDKDecodeError CResult_BlindedHopDecodeErrorZ_get_err(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
564         LDKDecodeError ret = *owner->contents.err;
565         ret.is_owned = false;
566         return ret;
567 }
568 uint64_t  __attribute__((export_name("TS_CResult_BlindedHopDecodeErrorZ_get_err"))) TS_CResult_BlindedHopDecodeErrorZ_get_err(uint64_t owner) {
569         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
570         LDKDecodeError ret_var = CResult_BlindedHopDecodeErrorZ_get_err(owner_conv);
571         uint64_t ret_ref = 0;
572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
573         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
574         return ret_ref;
575 }
576
577 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
578 CHECK(owner->result_ok);
579         return *owner->contents.result;
580 }
581 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint64_t owner) {
582         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
583         CResult_NoneNoneZ_get_ok(owner_conv);
584 }
585
586 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
587 CHECK(!owner->result_ok);
588         return *owner->contents.err;
589 }
590 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint64_t owner) {
591         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
592         CResult_NoneNoneZ_get_err(owner_conv);
593 }
594
595 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
596         LDKCounterpartyCommitmentSecrets ret = *owner->contents.result;
597         ret.is_owned = false;
598         return ret;
599 }
600 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(uint64_t owner) {
601         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
602         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
603         uint64_t ret_ref = 0;
604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
605         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
606         return ret_ref;
607 }
608
609 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
610         LDKDecodeError ret = *owner->contents.err;
611         ret.is_owned = false;
612         return ret;
613 }
614 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(uint64_t owner) {
615         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
616         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
617         uint64_t ret_ref = 0;
618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
619         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
620         return ret_ref;
621 }
622
623 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
624 CHECK(owner->result_ok);
625         return *owner->contents.result;
626 }
627 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint64_t owner) {
628         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(owner);
629         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
630         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
631         return ret_arr;
632 }
633
634 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
635 CHECK(!owner->result_ok);
636         return *owner->contents.err;
637 }
638 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint64_t owner) {
639         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(owner);
640         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
641         return ret_conv;
642 }
643
644 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
645 CHECK(owner->result_ok);
646         return *owner->contents.result;
647 }
648 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint64_t owner) {
649         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
650         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
651         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
652         return ret_arr;
653 }
654
655 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
656 CHECK(!owner->result_ok);
657         return *owner->contents.err;
658 }
659 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint64_t owner) {
660         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
661         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
662         return ret_conv;
663 }
664
665 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
666         LDKTxCreationKeys ret = *owner->contents.result;
667         ret.is_owned = false;
668         return ret;
669 }
670 uint64_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint64_t owner) {
671         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
672         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
673         uint64_t ret_ref = 0;
674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
675         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
676         return ret_ref;
677 }
678
679 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
680         LDKDecodeError ret = *owner->contents.err;
681         ret.is_owned = false;
682         return ret;
683 }
684 uint64_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint64_t owner) {
685         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
686         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
687         uint64_t ret_ref = 0;
688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
690         return ret_ref;
691 }
692
693 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
694         LDKChannelPublicKeys ret = *owner->contents.result;
695         ret.is_owned = false;
696         return ret;
697 }
698 uint64_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint64_t owner) {
699         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
700         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
701         uint64_t ret_ref = 0;
702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
703         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
704         return ret_ref;
705 }
706
707 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
708         LDKDecodeError ret = *owner->contents.err;
709         ret.is_owned = false;
710         return ret;
711 }
712 uint64_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint64_t owner) {
713         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
714         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
715         uint64_t ret_ref = 0;
716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
717         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
718         return ret_ref;
719 }
720
721 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
722         LDKTxCreationKeys ret = *owner->contents.result;
723         ret.is_owned = false;
724         return ret;
725 }
726 uint64_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint64_t owner) {
727         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(owner);
728         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
729         uint64_t ret_ref = 0;
730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
731         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
732         return ret_ref;
733 }
734
735 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
736 CHECK(!owner->result_ok);
737         return *owner->contents.err;
738 }
739 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint64_t owner) {
740         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(owner);
741         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
742         return ret_conv;
743 }
744
745 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint64_t ptr) {
746         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
747         switch(obj->tag) {
748                 case LDKCOption_u32Z_Some: return 0;
749                 case LDKCOption_u32Z_None: return 1;
750                 default: abort();
751         }
752 }
753 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint64_t ptr) {
754         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
755         assert(obj->tag == LDKCOption_u32Z_Some);
756                         int32_t some_conv = obj->some;
757         return some_conv;
758 }
759 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
760         LDKHTLCOutputInCommitment ret = *owner->contents.result;
761         ret.is_owned = false;
762         return ret;
763 }
764 uint64_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint64_t owner) {
765         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
766         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
767         uint64_t ret_ref = 0;
768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
769         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
770         return ret_ref;
771 }
772
773 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
774         LDKDecodeError ret = *owner->contents.err;
775         ret.is_owned = false;
776         return ret;
777 }
778 uint64_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint64_t owner) {
779         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
780         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
781         uint64_t ret_ref = 0;
782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
783         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
784         return ret_ref;
785 }
786
787 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
788         LDKCounterpartyChannelTransactionParameters ret = *owner->contents.result;
789         ret.is_owned = false;
790         return ret;
791 }
792 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint64_t owner) {
793         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
794         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
795         uint64_t ret_ref = 0;
796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
798         return ret_ref;
799 }
800
801 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
802         LDKDecodeError ret = *owner->contents.err;
803         ret.is_owned = false;
804         return ret;
805 }
806 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint64_t owner) {
807         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
808         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
809         uint64_t ret_ref = 0;
810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
811         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
812         return ret_ref;
813 }
814
815 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
816         LDKChannelTransactionParameters ret = *owner->contents.result;
817         ret.is_owned = false;
818         return ret;
819 }
820 uint64_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint64_t owner) {
821         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
822         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
823         uint64_t ret_ref = 0;
824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
825         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
826         return ret_ref;
827 }
828
829 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
830         LDKDecodeError ret = *owner->contents.err;
831         ret.is_owned = false;
832         return ret;
833 }
834 uint64_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint64_t owner) {
835         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
836         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
837         uint64_t ret_ref = 0;
838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
839         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
840         return ret_ref;
841 }
842
843 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
844         LDKHolderCommitmentTransaction ret = *owner->contents.result;
845         ret.is_owned = false;
846         return ret;
847 }
848 uint64_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint64_t owner) {
849         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
850         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
851         uint64_t ret_ref = 0;
852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
853         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
854         return ret_ref;
855 }
856
857 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
858         LDKDecodeError ret = *owner->contents.err;
859         ret.is_owned = false;
860         return ret;
861 }
862 uint64_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint64_t owner) {
863         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
864         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
865         uint64_t ret_ref = 0;
866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
867         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
868         return ret_ref;
869 }
870
871 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
872         LDKBuiltCommitmentTransaction ret = *owner->contents.result;
873         ret.is_owned = false;
874         return ret;
875 }
876 uint64_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint64_t owner) {
877         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
878         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
879         uint64_t ret_ref = 0;
880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
881         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
882         return ret_ref;
883 }
884
885 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
886         LDKDecodeError ret = *owner->contents.err;
887         ret.is_owned = false;
888         return ret;
889 }
890 uint64_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint64_t owner) {
891         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
892         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
893         uint64_t ret_ref = 0;
894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
895         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
896         return ret_ref;
897 }
898
899 static inline struct LDKTrustedClosingTransaction CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
900         LDKTrustedClosingTransaction ret = *owner->contents.result;
901         ret.is_owned = false;
902         return ret;
903 }
904 uint64_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint64_t owner) {
905         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
906         LDKTrustedClosingTransaction ret_var = CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
907         uint64_t ret_ref = 0;
908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
910         return ret_ref;
911 }
912
913 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
914 CHECK(!owner->result_ok);
915         return *owner->contents.err;
916 }
917 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint64_t owner) {
918         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
919         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
920 }
921
922 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
923         LDKCommitmentTransaction ret = *owner->contents.result;
924         ret.is_owned = false;
925         return ret;
926 }
927 uint64_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint64_t owner) {
928         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
929         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
930         uint64_t ret_ref = 0;
931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
932         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
933         return ret_ref;
934 }
935
936 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
937         LDKDecodeError ret = *owner->contents.err;
938         ret.is_owned = false;
939         return ret;
940 }
941 uint64_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint64_t owner) {
942         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
943         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
944         uint64_t ret_ref = 0;
945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
946         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
947         return ret_ref;
948 }
949
950 static inline struct LDKTrustedCommitmentTransaction CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
951         LDKTrustedCommitmentTransaction ret = *owner->contents.result;
952         ret.is_owned = false;
953         return ret;
954 }
955 uint64_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint64_t owner) {
956         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
957         LDKTrustedCommitmentTransaction ret_var = CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
958         uint64_t ret_ref = 0;
959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
960         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
961         return ret_ref;
962 }
963
964 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
965 CHECK(!owner->result_ok);
966         return *owner->contents.err;
967 }
968 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint64_t owner) {
969         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
970         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
971 }
972
973 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
974 CHECK(owner->result_ok);
975         return *owner->contents.result;
976 }
977 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint64_t owner) {
978         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
979         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
980         ptrArray ret_arr = NULL;
981         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
982         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
983         for (size_t m = 0; m < ret_var.datalen; m++) {
984                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
985                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
986                 ret_arr_ptr[m] = ret_conv_12_arr;
987         }
988         
989         return ret_arr;
990 }
991
992 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
993 CHECK(!owner->result_ok);
994         return *owner->contents.err;
995 }
996 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint64_t owner) {
997         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
998         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
999 }
1000
1001 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1002         LDKShutdownScript ret = *owner->contents.result;
1003         ret.is_owned = false;
1004         return ret;
1005 }
1006 uint64_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint64_t owner) {
1007         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1008         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1009         uint64_t ret_ref = 0;
1010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1011         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1012         return ret_ref;
1013 }
1014
1015 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1016         LDKDecodeError ret = *owner->contents.err;
1017         ret.is_owned = false;
1018         return ret;
1019 }
1020 uint64_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint64_t owner) {
1021         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1022         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1023         uint64_t ret_ref = 0;
1024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1025         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1026         return ret_ref;
1027 }
1028
1029 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1030         LDKShutdownScript ret = *owner->contents.result;
1031         ret.is_owned = false;
1032         return ret;
1033 }
1034 uint64_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint64_t owner) {
1035         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1036         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1037         uint64_t ret_ref = 0;
1038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1039         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1040         return ret_ref;
1041 }
1042
1043 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1044         LDKInvalidShutdownScript ret = *owner->contents.err;
1045         ret.is_owned = false;
1046         return ret;
1047 }
1048 uint64_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint64_t owner) {
1049         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1050         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1051         uint64_t ret_ref = 0;
1052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1053         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1054         return ret_ref;
1055 }
1056
1057 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1058         LDKRouteHop ret = *owner->contents.result;
1059         ret.is_owned = false;
1060         return ret;
1061 }
1062 uint64_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint64_t owner) {
1063         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
1064         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
1065         uint64_t ret_ref = 0;
1066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1067         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1068         return ret_ref;
1069 }
1070
1071 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1072         LDKDecodeError ret = *owner->contents.err;
1073         ret.is_owned = false;
1074         return ret;
1075 }
1076 uint64_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint64_t owner) {
1077         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
1078         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1079         uint64_t ret_ref = 0;
1080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1081         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1082         return ret_ref;
1083 }
1084
1085 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1086         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1087         for (size_t i = 0; i < ret.datalen; i++) {
1088                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1089         }
1090         return ret;
1091 }
1092 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1093         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1094         for (size_t i = 0; i < ret.datalen; i++) {
1095                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1096         }
1097         return ret;
1098 }
1099 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1100         LDKRoute ret = *owner->contents.result;
1101         ret.is_owned = false;
1102         return ret;
1103 }
1104 uint64_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint64_t owner) {
1105         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
1106         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1107         uint64_t ret_ref = 0;
1108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1109         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1110         return ret_ref;
1111 }
1112
1113 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1114         LDKDecodeError ret = *owner->contents.err;
1115         ret.is_owned = false;
1116         return ret;
1117 }
1118 uint64_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint64_t owner) {
1119         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
1120         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1121         uint64_t ret_ref = 0;
1122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1123         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1124         return ret_ref;
1125 }
1126
1127 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1128         LDKRouteParameters ret = *owner->contents.result;
1129         ret.is_owned = false;
1130         return ret;
1131 }
1132 uint64_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint64_t owner) {
1133         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
1134         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1135         uint64_t ret_ref = 0;
1136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1137         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1138         return ret_ref;
1139 }
1140
1141 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1142         LDKDecodeError ret = *owner->contents.err;
1143         ret.is_owned = false;
1144         return ret;
1145 }
1146 uint64_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint64_t owner) {
1147         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
1148         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1149         uint64_t ret_ref = 0;
1150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1151         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1152         return ret_ref;
1153 }
1154
1155 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1156         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1157         for (size_t i = 0; i < ret.datalen; i++) {
1158                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1159         }
1160         return ret;
1161 }
1162 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint64_t ptr) {
1163         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
1164         switch(obj->tag) {
1165                 case LDKCOption_u64Z_Some: return 0;
1166                 case LDKCOption_u64Z_None: return 1;
1167                 default: abort();
1168         }
1169 }
1170 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint64_t ptr) {
1171         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
1172         assert(obj->tag == LDKCOption_u64Z_Some);
1173                         int64_t some_conv = obj->some;
1174         return some_conv;
1175 }
1176 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1177         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1178         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1179         return ret;
1180 }
1181 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1182         LDKPaymentParameters ret = *owner->contents.result;
1183         ret.is_owned = false;
1184         return ret;
1185 }
1186 uint64_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_get_ok(uint64_t owner) {
1187         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
1188         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1189         uint64_t ret_ref = 0;
1190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1191         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1192         return ret_ref;
1193 }
1194
1195 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1196         LDKDecodeError ret = *owner->contents.err;
1197         ret.is_owned = false;
1198         return ret;
1199 }
1200 uint64_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_err"))) TS_CResult_PaymentParametersDecodeErrorZ_get_err(uint64_t owner) {
1201         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
1202         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1203         uint64_t ret_ref = 0;
1204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1205         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1206         return ret_ref;
1207 }
1208
1209 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1210         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1211         for (size_t i = 0; i < ret.datalen; i++) {
1212                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1213         }
1214         return ret;
1215 }
1216 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1217         LDKRouteHint ret = *owner->contents.result;
1218         ret.is_owned = false;
1219         return ret;
1220 }
1221 uint64_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint64_t owner) {
1222         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
1223         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1224         uint64_t ret_ref = 0;
1225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1226         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1227         return ret_ref;
1228 }
1229
1230 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1231         LDKDecodeError ret = *owner->contents.err;
1232         ret.is_owned = false;
1233         return ret;
1234 }
1235 uint64_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint64_t owner) {
1236         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
1237         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1238         uint64_t ret_ref = 0;
1239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1240         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1241         return ret_ref;
1242 }
1243
1244 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1245         LDKRouteHintHop ret = *owner->contents.result;
1246         ret.is_owned = false;
1247         return ret;
1248 }
1249 uint64_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint64_t owner) {
1250         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
1251         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1252         uint64_t ret_ref = 0;
1253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1254         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1255         return ret_ref;
1256 }
1257
1258 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1259         LDKDecodeError ret = *owner->contents.err;
1260         ret.is_owned = false;
1261         return ret;
1262 }
1263 uint64_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint64_t owner) {
1264         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
1265         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1266         uint64_t ret_ref = 0;
1267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1268         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1269         return ret_ref;
1270 }
1271
1272 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1273         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1274         for (size_t i = 0; i < ret.datalen; i++) {
1275                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1276         }
1277         return ret;
1278 }
1279 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1280         LDKRoute ret = *owner->contents.result;
1281         ret.is_owned = false;
1282         return ret;
1283 }
1284 uint64_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint64_t owner) {
1285         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
1286         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1287         uint64_t ret_ref = 0;
1288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1289         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1290         return ret_ref;
1291 }
1292
1293 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1294         LDKLightningError ret = *owner->contents.err;
1295         ret.is_owned = false;
1296         return ret;
1297 }
1298 uint64_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint64_t owner) {
1299         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
1300         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1301         uint64_t ret_ref = 0;
1302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1303         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1304         return ret_ref;
1305 }
1306
1307 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint64_t ptr) {
1308         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
1309         switch(obj->tag) {
1310                 case LDKPaymentPurpose_InvoicePayment: return 0;
1311                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1312                 default: abort();
1313         }
1314 }
1315 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint64_t ptr) {
1316         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
1317         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1318                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1319                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1320         return payment_preimage_arr;
1321 }
1322 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint64_t ptr) {
1323         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
1324         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1325                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1326                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1327         return payment_secret_arr;
1328 }
1329 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint64_t ptr) {
1330         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
1331         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1332                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1333                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1334         return spontaneous_payment_arr;
1335 }
1336 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1337 CHECK(owner->result_ok);
1338         return PaymentPurpose_clone(&*owner->contents.result);
1339 }
1340 uint64_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_get_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_get_ok(uint64_t owner) {
1341         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
1342         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
1343         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
1344         uint64_t ret_ref = tag_ptr(ret_copy, true);
1345         return ret_ref;
1346 }
1347
1348 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1349         LDKDecodeError ret = *owner->contents.err;
1350         ret.is_owned = false;
1351         return ret;
1352 }
1353 uint64_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_get_err"))) TS_CResult_PaymentPurposeDecodeErrorZ_get_err(uint64_t owner) {
1354         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
1355         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
1356         uint64_t ret_ref = 0;
1357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1358         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1359         return ret_ref;
1360 }
1361
1362 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint64_t ptr) {
1363         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
1364         switch(obj->tag) {
1365                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1366                 case LDKClosureReason_HolderForceClosed: return 1;
1367                 case LDKClosureReason_CooperativeClosure: return 2;
1368                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1369                 case LDKClosureReason_FundingTimedOut: return 4;
1370                 case LDKClosureReason_ProcessingError: return 5;
1371                 case LDKClosureReason_DisconnectedPeer: return 6;
1372                 case LDKClosureReason_OutdatedChannelManager: return 7;
1373                 default: abort();
1374         }
1375 }
1376 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint64_t ptr) {
1377         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
1378         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1379                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1380                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1381         return peer_msg_conv;
1382 }
1383 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint64_t ptr) {
1384         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
1385         assert(obj->tag == LDKClosureReason_ProcessingError);
1386                         LDKStr err_str = obj->processing_error.err;
1387                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1388         return err_conv;
1389 }
1390 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint64_t ptr) {
1391         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
1392         switch(obj->tag) {
1393                 case LDKCOption_ClosureReasonZ_Some: return 0;
1394                 case LDKCOption_ClosureReasonZ_None: return 1;
1395                 default: abort();
1396         }
1397 }
1398 uint64_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint64_t ptr) {
1399         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
1400         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
1401                         uint64_t some_ref = tag_ptr(&obj->some, false);
1402         return some_ref;
1403 }
1404 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1405 CHECK(owner->result_ok);
1406         return COption_ClosureReasonZ_clone(&*owner->contents.result);
1407 }
1408 uint64_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint64_t owner) {
1409         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
1410         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
1411         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
1412         uint64_t ret_ref = tag_ptr(ret_copy, true);
1413         return ret_ref;
1414 }
1415
1416 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1417         LDKDecodeError ret = *owner->contents.err;
1418         ret.is_owned = false;
1419         return ret;
1420 }
1421 uint64_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint64_t owner) {
1422         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
1423         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
1424         uint64_t ret_ref = 0;
1425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1426         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1427         return ret_ref;
1428 }
1429
1430 uint32_t __attribute__((export_name("TS_LDKHTLCDestination_ty_from_ptr"))) TS_LDKHTLCDestination_ty_from_ptr(uint64_t ptr) {
1431         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
1432         switch(obj->tag) {
1433                 case LDKHTLCDestination_NextHopChannel: return 0;
1434                 case LDKHTLCDestination_UnknownNextHop: return 1;
1435                 case LDKHTLCDestination_FailedPayment: return 2;
1436                 default: abort();
1437         }
1438 }
1439 int8_tArray __attribute__((export_name("TS_LDKHTLCDestination_NextHopChannel_get_node_id"))) TS_LDKHTLCDestination_NextHopChannel_get_node_id(uint64_t ptr) {
1440         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
1441         assert(obj->tag == LDKHTLCDestination_NextHopChannel);
1442                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1443                         memcpy(node_id_arr->elems, obj->next_hop_channel.node_id.compressed_form, 33);
1444         return node_id_arr;
1445 }
1446 int8_tArray __attribute__((export_name("TS_LDKHTLCDestination_NextHopChannel_get_channel_id"))) TS_LDKHTLCDestination_NextHopChannel_get_channel_id(uint64_t ptr) {
1447         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
1448         assert(obj->tag == LDKHTLCDestination_NextHopChannel);
1449                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1450                         memcpy(channel_id_arr->elems, obj->next_hop_channel.channel_id.data, 32);
1451         return channel_id_arr;
1452 }
1453 int64_t __attribute__((export_name("TS_LDKHTLCDestination_UnknownNextHop_get_requested_forward_scid"))) TS_LDKHTLCDestination_UnknownNextHop_get_requested_forward_scid(uint64_t ptr) {
1454         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
1455         assert(obj->tag == LDKHTLCDestination_UnknownNextHop);
1456                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
1457         return requested_forward_scid_conv;
1458 }
1459 int8_tArray __attribute__((export_name("TS_LDKHTLCDestination_FailedPayment_get_payment_hash"))) TS_LDKHTLCDestination_FailedPayment_get_payment_hash(uint64_t ptr) {
1460         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
1461         assert(obj->tag == LDKHTLCDestination_FailedPayment);
1462                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1463                         memcpy(payment_hash_arr->elems, obj->failed_payment.payment_hash.data, 32);
1464         return payment_hash_arr;
1465 }
1466 uint32_t __attribute__((export_name("TS_LDKCOption_HTLCDestinationZ_ty_from_ptr"))) TS_LDKCOption_HTLCDestinationZ_ty_from_ptr(uint64_t ptr) {
1467         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
1468         switch(obj->tag) {
1469                 case LDKCOption_HTLCDestinationZ_Some: return 0;
1470                 case LDKCOption_HTLCDestinationZ_None: return 1;
1471                 default: abort();
1472         }
1473 }
1474 uint64_t __attribute__((export_name("TS_LDKCOption_HTLCDestinationZ_Some_get_some"))) TS_LDKCOption_HTLCDestinationZ_Some_get_some(uint64_t ptr) {
1475         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
1476         assert(obj->tag == LDKCOption_HTLCDestinationZ_Some);
1477                         uint64_t some_ref = tag_ptr(&obj->some, false);
1478         return some_ref;
1479 }
1480 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
1481 CHECK(owner->result_ok);
1482         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
1483 }
1484 uint64_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(uint64_t owner) {
1485         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
1486         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
1487         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
1488         uint64_t ret_ref = tag_ptr(ret_copy, true);
1489         return ret_ref;
1490 }
1491
1492 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
1493         LDKDecodeError ret = *owner->contents.err;
1494         ret.is_owned = false;
1495         return ret;
1496 }
1497 uint64_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_err"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(uint64_t owner) {
1498         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
1499         LDKDecodeError ret_var = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
1500         uint64_t ret_ref = 0;
1501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1502         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1503         return ret_ref;
1504 }
1505
1506 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint64_t ptr) {
1507         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
1508         switch(obj->tag) {
1509                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1510                 case LDKNetworkUpdate_ChannelFailure: return 1;
1511                 case LDKNetworkUpdate_NodeFailure: return 2;
1512                 default: abort();
1513         }
1514 }
1515 uint64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint64_t ptr) {
1516         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
1517         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1518                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1519                         uint64_t msg_ref = 0;
1520                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1521                         msg_ref = tag_ptr(msg_var.inner, false);
1522         return msg_ref;
1523 }
1524 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelFailure_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelFailure_get_short_channel_id(uint64_t ptr) {
1525         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
1526         assert(obj->tag == LDKNetworkUpdate_ChannelFailure);
1527                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
1528         return short_channel_id_conv;
1529 }
1530 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelFailure_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelFailure_get_is_permanent(uint64_t ptr) {
1531         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
1532         assert(obj->tag == LDKNetworkUpdate_ChannelFailure);
1533                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
1534         return is_permanent_conv;
1535 }
1536 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint64_t ptr) {
1537         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
1538         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1539                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1540                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1541         return node_id_arr;
1542 }
1543 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint64_t ptr) {
1544         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
1545         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1546                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
1547         return is_permanent_conv;
1548 }
1549 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint64_t ptr) {
1550         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
1551         switch(obj->tag) {
1552                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1553                 case LDKCOption_NetworkUpdateZ_None: return 1;
1554                 default: abort();
1555         }
1556 }
1557 uint64_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint64_t ptr) {
1558         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
1559         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1560                         uint64_t some_ref = tag_ptr(&obj->some, false);
1561         return some_ref;
1562 }
1563 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint64_t ptr) {
1564         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1565         switch(obj->tag) {
1566                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1567                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1568                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1569                 default: abort();
1570         }
1571 }
1572 uint64_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint64_t ptr) {
1573         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1574         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1575                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1576                         uint64_t outpoint_ref = 0;
1577                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1578                         outpoint_ref = tag_ptr(outpoint_var.inner, false);
1579         return outpoint_ref;
1580 }
1581 uint64_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint64_t ptr) {
1582         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1583         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1584                         LDKTxOut* output_ref = &obj->static_output.output;
1585         return tag_ptr(output_ref, false);
1586 }
1587 uint64_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint64_t ptr) {
1588         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1589         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1590                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1591                         uint64_t delayed_payment_output_ref = 0;
1592                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1593                         delayed_payment_output_ref = tag_ptr(delayed_payment_output_var.inner, false);
1594         return delayed_payment_output_ref;
1595 }
1596 uint64_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint64_t ptr) {
1597         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1598         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1599                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1600                         uint64_t static_payment_output_ref = 0;
1601                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1602                         static_payment_output_ref = tag_ptr(static_payment_output_var.inner, false);
1603         return static_payment_output_ref;
1604 }
1605 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1606         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1607         for (size_t i = 0; i < ret.datalen; i++) {
1608                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1609         }
1610         return ret;
1611 }
1612 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint64_t ptr) {
1613         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1614         switch(obj->tag) {
1615                 case LDKEvent_FundingGenerationReady: return 0;
1616                 case LDKEvent_PaymentReceived: return 1;
1617                 case LDKEvent_PaymentClaimed: return 2;
1618                 case LDKEvent_PaymentSent: return 3;
1619                 case LDKEvent_PaymentFailed: return 4;
1620                 case LDKEvent_PaymentPathSuccessful: return 5;
1621                 case LDKEvent_PaymentPathFailed: return 6;
1622                 case LDKEvent_ProbeSuccessful: return 7;
1623                 case LDKEvent_ProbeFailed: return 8;
1624                 case LDKEvent_PendingHTLCsForwardable: return 9;
1625                 case LDKEvent_SpendableOutputs: return 10;
1626                 case LDKEvent_PaymentForwarded: return 11;
1627                 case LDKEvent_ChannelClosed: return 12;
1628                 case LDKEvent_DiscardFunding: return 13;
1629                 case LDKEvent_OpenChannelRequest: return 14;
1630                 case LDKEvent_HTLCHandlingFailed: return 15;
1631                 default: abort();
1632         }
1633 }
1634 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint64_t ptr) {
1635         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1636         assert(obj->tag == LDKEvent_FundingGenerationReady);
1637                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1638                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1639         return temporary_channel_id_arr;
1640 }
1641 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_counterparty_node_id"))) TS_LDKEvent_FundingGenerationReady_get_counterparty_node_id(uint64_t ptr) {
1642         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1643         assert(obj->tag == LDKEvent_FundingGenerationReady);
1644                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1645                         memcpy(counterparty_node_id_arr->elems, obj->funding_generation_ready.counterparty_node_id.compressed_form, 33);
1646         return counterparty_node_id_arr;
1647 }
1648 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint64_t ptr) {
1649         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1650         assert(obj->tag == LDKEvent_FundingGenerationReady);
1651                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
1652         return channel_value_satoshis_conv;
1653 }
1654 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint64_t ptr) {
1655         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1656         assert(obj->tag == LDKEvent_FundingGenerationReady);
1657                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1658                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1659                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1660         return output_script_arr;
1661 }
1662 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint64_t ptr) {
1663         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1664         assert(obj->tag == LDKEvent_FundingGenerationReady);
1665                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
1666         return user_channel_id_conv;
1667 }
1668 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint64_t ptr) {
1669         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1670         assert(obj->tag == LDKEvent_PaymentReceived);
1671                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1672                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1673         return payment_hash_arr;
1674 }
1675 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amount_msat"))) TS_LDKEvent_PaymentReceived_get_amount_msat(uint64_t ptr) {
1676         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1677         assert(obj->tag == LDKEvent_PaymentReceived);
1678                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
1679         return amount_msat_conv;
1680 }
1681 uint64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint64_t ptr) {
1682         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1683         assert(obj->tag == LDKEvent_PaymentReceived);
1684                         uint64_t purpose_ref = tag_ptr(&obj->payment_received.purpose, false);
1685         return purpose_ref;
1686 }
1687 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_payment_hash"))) TS_LDKEvent_PaymentClaimed_get_payment_hash(uint64_t ptr) {
1688         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1689         assert(obj->tag == LDKEvent_PaymentClaimed);
1690                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1691                         memcpy(payment_hash_arr->elems, obj->payment_claimed.payment_hash.data, 32);
1692         return payment_hash_arr;
1693 }
1694 int64_t __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_amount_msat"))) TS_LDKEvent_PaymentClaimed_get_amount_msat(uint64_t ptr) {
1695         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1696         assert(obj->tag == LDKEvent_PaymentClaimed);
1697                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
1698         return amount_msat_conv;
1699 }
1700 uint64_t __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_purpose"))) TS_LDKEvent_PaymentClaimed_get_purpose(uint64_t ptr) {
1701         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1702         assert(obj->tag == LDKEvent_PaymentClaimed);
1703                         uint64_t purpose_ref = tag_ptr(&obj->payment_claimed.purpose, false);
1704         return purpose_ref;
1705 }
1706 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint64_t ptr) {
1707         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1708         assert(obj->tag == LDKEvent_PaymentSent);
1709                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1710                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1711         return payment_id_arr;
1712 }
1713 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint64_t ptr) {
1714         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1715         assert(obj->tag == LDKEvent_PaymentSent);
1716                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1717                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1718         return payment_preimage_arr;
1719 }
1720 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint64_t ptr) {
1721         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1722         assert(obj->tag == LDKEvent_PaymentSent);
1723                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1724                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1725         return payment_hash_arr;
1726 }
1727 uint64_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint64_t ptr) {
1728         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1729         assert(obj->tag == LDKEvent_PaymentSent);
1730                         uint64_t fee_paid_msat_ref = tag_ptr(&obj->payment_sent.fee_paid_msat, false);
1731         return fee_paid_msat_ref;
1732 }
1733 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint64_t ptr) {
1734         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1735         assert(obj->tag == LDKEvent_PaymentFailed);
1736                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1737                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1738         return payment_id_arr;
1739 }
1740 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint64_t ptr) {
1741         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1742         assert(obj->tag == LDKEvent_PaymentFailed);
1743                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1744                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1745         return payment_hash_arr;
1746 }
1747 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint64_t ptr) {
1748         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1749         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1750                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1751                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1752         return payment_id_arr;
1753 }
1754 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint64_t ptr) {
1755         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1756         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1757                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1758                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1759         return payment_hash_arr;
1760 }
1761 uint64_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint64_t ptr) {
1762         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1763         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1764                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1765                         uint64_tArray path_arr = NULL;
1766                         path_arr = init_uint64_tArray(path_var.datalen, __LINE__);
1767                         uint64_t *path_arr_ptr = (uint64_t*)(((uint8_t*)path_arr) + 8);
1768                         for (size_t k = 0; k < path_var.datalen; k++) {
1769                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1770                                 uint64_t path_conv_10_ref = 0;
1771                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1772                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
1773                                 path_arr_ptr[k] = path_conv_10_ref;
1774                         }
1775                         
1776         return path_arr;
1777 }
1778 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint64_t ptr) {
1779         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1780         assert(obj->tag == LDKEvent_PaymentPathFailed);
1781                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1782                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1783         return payment_id_arr;
1784 }
1785 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint64_t ptr) {
1786         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1787         assert(obj->tag == LDKEvent_PaymentPathFailed);
1788                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1789                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1790         return payment_hash_arr;
1791 }
1792 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_failed_permanently"))) TS_LDKEvent_PaymentPathFailed_get_payment_failed_permanently(uint64_t ptr) {
1793         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1794         assert(obj->tag == LDKEvent_PaymentPathFailed);
1795                         jboolean payment_failed_permanently_conv = obj->payment_path_failed.payment_failed_permanently;
1796         return payment_failed_permanently_conv;
1797 }
1798 uint64_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint64_t ptr) {
1799         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1800         assert(obj->tag == LDKEvent_PaymentPathFailed);
1801                         uint64_t network_update_ref = tag_ptr(&obj->payment_path_failed.network_update, false);
1802         return network_update_ref;
1803 }
1804 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint64_t ptr) {
1805         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1806         assert(obj->tag == LDKEvent_PaymentPathFailed);
1807                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
1808         return all_paths_failed_conv;
1809 }
1810 uint64_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint64_t ptr) {
1811         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1812         assert(obj->tag == LDKEvent_PaymentPathFailed);
1813                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1814                         uint64_tArray path_arr = NULL;
1815                         path_arr = init_uint64_tArray(path_var.datalen, __LINE__);
1816                         uint64_t *path_arr_ptr = (uint64_t*)(((uint8_t*)path_arr) + 8);
1817                         for (size_t k = 0; k < path_var.datalen; k++) {
1818                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1819                                 uint64_t path_conv_10_ref = 0;
1820                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1821                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
1822                                 path_arr_ptr[k] = path_conv_10_ref;
1823                         }
1824                         
1825         return path_arr;
1826 }
1827 uint64_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint64_t ptr) {
1828         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1829         assert(obj->tag == LDKEvent_PaymentPathFailed);
1830                         uint64_t short_channel_id_ref = tag_ptr(&obj->payment_path_failed.short_channel_id, false);
1831         return short_channel_id_ref;
1832 }
1833 uint64_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint64_t ptr) {
1834         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1835         assert(obj->tag == LDKEvent_PaymentPathFailed);
1836                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1837                         uint64_t retry_ref = 0;
1838                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1839                         retry_ref = tag_ptr(retry_var.inner, false);
1840         return retry_ref;
1841 }
1842 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeSuccessful_get_payment_id"))) TS_LDKEvent_ProbeSuccessful_get_payment_id(uint64_t ptr) {
1843         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1844         assert(obj->tag == LDKEvent_ProbeSuccessful);
1845                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1846                         memcpy(payment_id_arr->elems, obj->probe_successful.payment_id.data, 32);
1847         return payment_id_arr;
1848 }
1849 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeSuccessful_get_payment_hash"))) TS_LDKEvent_ProbeSuccessful_get_payment_hash(uint64_t ptr) {
1850         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1851         assert(obj->tag == LDKEvent_ProbeSuccessful);
1852                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1853                         memcpy(payment_hash_arr->elems, obj->probe_successful.payment_hash.data, 32);
1854         return payment_hash_arr;
1855 }
1856 uint64_tArray __attribute__((export_name("TS_LDKEvent_ProbeSuccessful_get_path"))) TS_LDKEvent_ProbeSuccessful_get_path(uint64_t ptr) {
1857         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1858         assert(obj->tag == LDKEvent_ProbeSuccessful);
1859                         LDKCVec_RouteHopZ path_var = obj->probe_successful.path;
1860                         uint64_tArray path_arr = NULL;
1861                         path_arr = init_uint64_tArray(path_var.datalen, __LINE__);
1862                         uint64_t *path_arr_ptr = (uint64_t*)(((uint8_t*)path_arr) + 8);
1863                         for (size_t k = 0; k < path_var.datalen; k++) {
1864                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1865                                 uint64_t path_conv_10_ref = 0;
1866                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1867                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
1868                                 path_arr_ptr[k] = path_conv_10_ref;
1869                         }
1870                         
1871         return path_arr;
1872 }
1873 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_payment_id"))) TS_LDKEvent_ProbeFailed_get_payment_id(uint64_t ptr) {
1874         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1875         assert(obj->tag == LDKEvent_ProbeFailed);
1876                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1877                         memcpy(payment_id_arr->elems, obj->probe_failed.payment_id.data, 32);
1878         return payment_id_arr;
1879 }
1880 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_payment_hash"))) TS_LDKEvent_ProbeFailed_get_payment_hash(uint64_t ptr) {
1881         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1882         assert(obj->tag == LDKEvent_ProbeFailed);
1883                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1884                         memcpy(payment_hash_arr->elems, obj->probe_failed.payment_hash.data, 32);
1885         return payment_hash_arr;
1886 }
1887 uint64_tArray __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_path"))) TS_LDKEvent_ProbeFailed_get_path(uint64_t ptr) {
1888         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1889         assert(obj->tag == LDKEvent_ProbeFailed);
1890                         LDKCVec_RouteHopZ path_var = obj->probe_failed.path;
1891                         uint64_tArray path_arr = NULL;
1892                         path_arr = init_uint64_tArray(path_var.datalen, __LINE__);
1893                         uint64_t *path_arr_ptr = (uint64_t*)(((uint8_t*)path_arr) + 8);
1894                         for (size_t k = 0; k < path_var.datalen; k++) {
1895                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1896                                 uint64_t path_conv_10_ref = 0;
1897                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1898                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
1899                                 path_arr_ptr[k] = path_conv_10_ref;
1900                         }
1901                         
1902         return path_arr;
1903 }
1904 uint64_t __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_short_channel_id"))) TS_LDKEvent_ProbeFailed_get_short_channel_id(uint64_t ptr) {
1905         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1906         assert(obj->tag == LDKEvent_ProbeFailed);
1907                         uint64_t short_channel_id_ref = tag_ptr(&obj->probe_failed.short_channel_id, false);
1908         return short_channel_id_ref;
1909 }
1910 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint64_t ptr) {
1911         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1912         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1913                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
1914         return time_forwardable_conv;
1915 }
1916 uint64_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint64_t ptr) {
1917         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1918         assert(obj->tag == LDKEvent_SpendableOutputs);
1919                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1920                         uint64_tArray outputs_arr = NULL;
1921                         outputs_arr = init_uint64_tArray(outputs_var.datalen, __LINE__);
1922                         uint64_t *outputs_arr_ptr = (uint64_t*)(((uint8_t*)outputs_arr) + 8);
1923                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1924                                 uint64_t outputs_conv_27_ref = tag_ptr(&outputs_var.data[b], false);
1925                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1926                         }
1927                         
1928         return outputs_arr;
1929 }
1930 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_prev_channel_id"))) TS_LDKEvent_PaymentForwarded_get_prev_channel_id(uint64_t ptr) {
1931         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1932         assert(obj->tag == LDKEvent_PaymentForwarded);
1933                         int8_tArray prev_channel_id_arr = init_int8_tArray(32, __LINE__);
1934                         memcpy(prev_channel_id_arr->elems, obj->payment_forwarded.prev_channel_id.data, 32);
1935         return prev_channel_id_arr;
1936 }
1937 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_next_channel_id"))) TS_LDKEvent_PaymentForwarded_get_next_channel_id(uint64_t ptr) {
1938         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1939         assert(obj->tag == LDKEvent_PaymentForwarded);
1940                         int8_tArray next_channel_id_arr = init_int8_tArray(32, __LINE__);
1941                         memcpy(next_channel_id_arr->elems, obj->payment_forwarded.next_channel_id.data, 32);
1942         return next_channel_id_arr;
1943 }
1944 uint64_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint64_t ptr) {
1945         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1946         assert(obj->tag == LDKEvent_PaymentForwarded);
1947                         uint64_t fee_earned_msat_ref = tag_ptr(&obj->payment_forwarded.fee_earned_msat, false);
1948         return fee_earned_msat_ref;
1949 }
1950 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint64_t ptr) {
1951         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1952         assert(obj->tag == LDKEvent_PaymentForwarded);
1953                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
1954         return claim_from_onchain_tx_conv;
1955 }
1956 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint64_t ptr) {
1957         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1958         assert(obj->tag == LDKEvent_ChannelClosed);
1959                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1960                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1961         return channel_id_arr;
1962 }
1963 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint64_t ptr) {
1964         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1965         assert(obj->tag == LDKEvent_ChannelClosed);
1966                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
1967         return user_channel_id_conv;
1968 }
1969 uint64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint64_t ptr) {
1970         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1971         assert(obj->tag == LDKEvent_ChannelClosed);
1972                         uint64_t reason_ref = tag_ptr(&obj->channel_closed.reason, false);
1973         return reason_ref;
1974 }
1975 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint64_t ptr) {
1976         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1977         assert(obj->tag == LDKEvent_DiscardFunding);
1978                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1979                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
1980         return channel_id_arr;
1981 }
1982 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint64_t ptr) {
1983         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1984         assert(obj->tag == LDKEvent_DiscardFunding);
1985                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1986                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
1987                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
1988         return transaction_arr;
1989 }
1990 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id"))) TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id(uint64_t ptr) {
1991         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1992         assert(obj->tag == LDKEvent_OpenChannelRequest);
1993                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1994                         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
1995         return temporary_channel_id_arr;
1996 }
1997 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id"))) TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id(uint64_t ptr) {
1998         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
1999         assert(obj->tag == LDKEvent_OpenChannelRequest);
2000                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
2001                         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
2002         return counterparty_node_id_arr;
2003 }
2004 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_funding_satoshis"))) TS_LDKEvent_OpenChannelRequest_get_funding_satoshis(uint64_t ptr) {
2005         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
2006         assert(obj->tag == LDKEvent_OpenChannelRequest);
2007                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
2008         return funding_satoshis_conv;
2009 }
2010 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_push_msat"))) TS_LDKEvent_OpenChannelRequest_get_push_msat(uint64_t ptr) {
2011         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
2012         assert(obj->tag == LDKEvent_OpenChannelRequest);
2013                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
2014         return push_msat_conv;
2015 }
2016 uint64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_channel_type"))) TS_LDKEvent_OpenChannelRequest_get_channel_type(uint64_t ptr) {
2017         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
2018         assert(obj->tag == LDKEvent_OpenChannelRequest);
2019                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
2020                         uint64_t channel_type_ref = 0;
2021                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
2022                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
2023         return channel_type_ref;
2024 }
2025 int8_tArray __attribute__((export_name("TS_LDKEvent_HTLCHandlingFailed_get_prev_channel_id"))) TS_LDKEvent_HTLCHandlingFailed_get_prev_channel_id(uint64_t ptr) {
2026         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
2027         assert(obj->tag == LDKEvent_HTLCHandlingFailed);
2028                         int8_tArray prev_channel_id_arr = init_int8_tArray(32, __LINE__);
2029                         memcpy(prev_channel_id_arr->elems, obj->htlc_handling_failed.prev_channel_id.data, 32);
2030         return prev_channel_id_arr;
2031 }
2032 uint64_t __attribute__((export_name("TS_LDKEvent_HTLCHandlingFailed_get_failed_next_destination"))) TS_LDKEvent_HTLCHandlingFailed_get_failed_next_destination(uint64_t ptr) {
2033         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
2034         assert(obj->tag == LDKEvent_HTLCHandlingFailed);
2035                         uint64_t failed_next_destination_ref = tag_ptr(&obj->htlc_handling_failed.failed_next_destination, false);
2036         return failed_next_destination_ref;
2037 }
2038 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint64_t ptr) {
2039         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
2040         switch(obj->tag) {
2041                 case LDKCOption_EventZ_Some: return 0;
2042                 case LDKCOption_EventZ_None: return 1;
2043                 default: abort();
2044         }
2045 }
2046 uint64_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint64_t ptr) {
2047         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
2048         assert(obj->tag == LDKCOption_EventZ_Some);
2049                         uint64_t some_ref = tag_ptr(&obj->some, false);
2050         return some_ref;
2051 }
2052 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2053 CHECK(owner->result_ok);
2054         return COption_EventZ_clone(&*owner->contents.result);
2055 }
2056 uint64_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint64_t owner) {
2057         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
2058         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2059         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2060         uint64_t ret_ref = tag_ptr(ret_copy, true);
2061         return ret_ref;
2062 }
2063
2064 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2065         LDKDecodeError ret = *owner->contents.err;
2066         ret.is_owned = false;
2067         return ret;
2068 }
2069 uint64_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint64_t owner) {
2070         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
2071         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2072         uint64_t ret_ref = 0;
2073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2074         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2075         return ret_ref;
2076 }
2077
2078 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint64_t ptr) {
2079         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
2080         switch(obj->tag) {
2081                 case LDKErrorAction_DisconnectPeer: return 0;
2082                 case LDKErrorAction_IgnoreError: return 1;
2083                 case LDKErrorAction_IgnoreAndLog: return 2;
2084                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
2085                 case LDKErrorAction_SendErrorMessage: return 4;
2086                 case LDKErrorAction_SendWarningMessage: return 5;
2087                 default: abort();
2088         }
2089 }
2090 uint64_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint64_t ptr) {
2091         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
2092         assert(obj->tag == LDKErrorAction_DisconnectPeer);
2093                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2094                         uint64_t msg_ref = 0;
2095                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2096                         msg_ref = tag_ptr(msg_var.inner, false);
2097         return msg_ref;
2098 }
2099 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint64_t ptr) {
2100         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
2101         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
2102                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
2103         return ignore_and_log_conv;
2104 }
2105 uint64_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint64_t ptr) {
2106         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
2107         assert(obj->tag == LDKErrorAction_SendErrorMessage);
2108                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2109                         uint64_t msg_ref = 0;
2110                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2111                         msg_ref = tag_ptr(msg_var.inner, false);
2112         return msg_ref;
2113 }
2114 uint64_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_msg"))) TS_LDKErrorAction_SendWarningMessage_get_msg(uint64_t ptr) {
2115         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
2116         assert(obj->tag == LDKErrorAction_SendWarningMessage);
2117                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2118                         uint64_t msg_ref = 0;
2119                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2120                         msg_ref = tag_ptr(msg_var.inner, false);
2121         return msg_ref;
2122 }
2123 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_log_level"))) TS_LDKErrorAction_SendWarningMessage_get_log_level(uint64_t ptr) {
2124         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
2125         assert(obj->tag == LDKErrorAction_SendWarningMessage);
2126                         uint32_t log_level_conv = LDKLevel_to_js(obj->send_warning_message.log_level);
2127         return log_level_conv;
2128 }
2129 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint64_t ptr) {
2130         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2131         switch(obj->tag) {
2132                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
2133                 case LDKMessageSendEvent_SendOpenChannel: return 1;
2134                 case LDKMessageSendEvent_SendFundingCreated: return 2;
2135                 case LDKMessageSendEvent_SendFundingSigned: return 3;
2136                 case LDKMessageSendEvent_SendChannelReady: return 4;
2137                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
2138                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
2139                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
2140                 case LDKMessageSendEvent_SendClosingSigned: return 8;
2141                 case LDKMessageSendEvent_SendShutdown: return 9;
2142                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
2143                 case LDKMessageSendEvent_SendChannelAnnouncement: return 11;
2144                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 12;
2145                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
2146                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
2147                 case LDKMessageSendEvent_HandleError: return 15;
2148                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
2149                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2150                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2151                 case LDKMessageSendEvent_SendGossipTimestampFilter: return 19;
2152                 default: abort();
2153         }
2154 }
2155 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint64_t ptr) {
2156         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2157         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2158                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2159                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2160         return node_id_arr;
2161 }
2162 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint64_t ptr) {
2163         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2164         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2165                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2166                         uint64_t msg_ref = 0;
2167                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2168                         msg_ref = tag_ptr(msg_var.inner, false);
2169         return msg_ref;
2170 }
2171 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint64_t ptr) {
2172         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2173         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2174                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2175                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2176         return node_id_arr;
2177 }
2178 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint64_t ptr) {
2179         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2180         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2181                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2182                         uint64_t msg_ref = 0;
2183                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2184                         msg_ref = tag_ptr(msg_var.inner, false);
2185         return msg_ref;
2186 }
2187 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint64_t ptr) {
2188         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2189         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2190                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2191                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2192         return node_id_arr;
2193 }
2194 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint64_t ptr) {
2195         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2196         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2197                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2198                         uint64_t msg_ref = 0;
2199                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2200                         msg_ref = tag_ptr(msg_var.inner, false);
2201         return msg_ref;
2202 }
2203 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint64_t ptr) {
2204         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2205         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2206                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2207                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2208         return node_id_arr;
2209 }
2210 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint64_t ptr) {
2211         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2212         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2213                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2214                         uint64_t msg_ref = 0;
2215                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2216                         msg_ref = tag_ptr(msg_var.inner, false);
2217         return msg_ref;
2218 }
2219 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReady_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReady_get_node_id(uint64_t ptr) {
2220         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2221         assert(obj->tag == LDKMessageSendEvent_SendChannelReady);
2222                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2223                         memcpy(node_id_arr->elems, obj->send_channel_ready.node_id.compressed_form, 33);
2224         return node_id_arr;
2225 }
2226 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReady_get_msg"))) TS_LDKMessageSendEvent_SendChannelReady_get_msg(uint64_t ptr) {
2227         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2228         assert(obj->tag == LDKMessageSendEvent_SendChannelReady);
2229                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
2230                         uint64_t msg_ref = 0;
2231                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2232                         msg_ref = tag_ptr(msg_var.inner, false);
2233         return msg_ref;
2234 }
2235 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint64_t ptr) {
2236         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2237         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2238                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2239                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
2240         return node_id_arr;
2241 }
2242 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint64_t ptr) {
2243         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2244         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2245                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2246                         uint64_t msg_ref = 0;
2247                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2248                         msg_ref = tag_ptr(msg_var.inner, false);
2249         return msg_ref;
2250 }
2251 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint64_t ptr) {
2252         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2253         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2254                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2255                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
2256         return node_id_arr;
2257 }
2258 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint64_t ptr) {
2259         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2260         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2261                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2262                         uint64_t updates_ref = 0;
2263                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2264                         updates_ref = tag_ptr(updates_var.inner, false);
2265         return updates_ref;
2266 }
2267 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint64_t ptr) {
2268         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2269         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2270                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2271                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
2272         return node_id_arr;
2273 }
2274 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint64_t ptr) {
2275         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2276         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2277                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2278                         uint64_t msg_ref = 0;
2279                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2280                         msg_ref = tag_ptr(msg_var.inner, false);
2281         return msg_ref;
2282 }
2283 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint64_t ptr) {
2284         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2285         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2286                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2287                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
2288         return node_id_arr;
2289 }
2290 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint64_t ptr) {
2291         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2292         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2293                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2294                         uint64_t msg_ref = 0;
2295                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2296                         msg_ref = tag_ptr(msg_var.inner, false);
2297         return msg_ref;
2298 }
2299 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint64_t ptr) {
2300         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2301         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2302                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2303                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
2304         return node_id_arr;
2305 }
2306 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint64_t ptr) {
2307         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2308         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2309                         LDKShutdown msg_var = obj->send_shutdown.msg;
2310                         uint64_t msg_ref = 0;
2311                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2312                         msg_ref = tag_ptr(msg_var.inner, false);
2313         return msg_ref;
2314 }
2315 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint64_t ptr) {
2316         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2317         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2318                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2319                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
2320         return node_id_arr;
2321 }
2322 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint64_t ptr) {
2323         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2324         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2325                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2326                         uint64_t msg_ref = 0;
2327                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2328                         msg_ref = tag_ptr(msg_var.inner, false);
2329         return msg_ref;
2330 }
2331 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelAnnouncement_get_node_id"))) TS_LDKMessageSendEvent_SendChannelAnnouncement_get_node_id(uint64_t ptr) {
2332         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2333         assert(obj->tag == LDKMessageSendEvent_SendChannelAnnouncement);
2334                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2335                         memcpy(node_id_arr->elems, obj->send_channel_announcement.node_id.compressed_form, 33);
2336         return node_id_arr;
2337 }
2338 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_SendChannelAnnouncement_get_msg(uint64_t ptr) {
2339         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2340         assert(obj->tag == LDKMessageSendEvent_SendChannelAnnouncement);
2341                         LDKChannelAnnouncement msg_var = obj->send_channel_announcement.msg;
2342                         uint64_t msg_ref = 0;
2343                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2344                         msg_ref = tag_ptr(msg_var.inner, false);
2345         return msg_ref;
2346 }
2347 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_SendChannelAnnouncement_get_update_msg(uint64_t ptr) {
2348         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2349         assert(obj->tag == LDKMessageSendEvent_SendChannelAnnouncement);
2350                         LDKChannelUpdate update_msg_var = obj->send_channel_announcement.update_msg;
2351                         uint64_t update_msg_ref = 0;
2352                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2353                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
2354         return update_msg_ref;
2355 }
2356 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint64_t ptr) {
2357         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2358         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2359                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2360                         uint64_t msg_ref = 0;
2361                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2362                         msg_ref = tag_ptr(msg_var.inner, false);
2363         return msg_ref;
2364 }
2365 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint64_t ptr) {
2366         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2367         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2368                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2369                         uint64_t update_msg_ref = 0;
2370                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2371                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
2372         return update_msg_ref;
2373 }
2374 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint64_t ptr) {
2375         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2376         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
2377                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2378                         uint64_t msg_ref = 0;
2379                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2380                         msg_ref = tag_ptr(msg_var.inner, false);
2381         return msg_ref;
2382 }
2383 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint64_t ptr) {
2384         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2385         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2386                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2387                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
2388         return node_id_arr;
2389 }
2390 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint64_t ptr) {
2391         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2392         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2393                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2394                         uint64_t msg_ref = 0;
2395                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2396                         msg_ref = tag_ptr(msg_var.inner, false);
2397         return msg_ref;
2398 }
2399 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint64_t ptr) {
2400         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2401         assert(obj->tag == LDKMessageSendEvent_HandleError);
2402                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2403                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
2404         return node_id_arr;
2405 }
2406 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint64_t ptr) {
2407         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2408         assert(obj->tag == LDKMessageSendEvent_HandleError);
2409                         uint64_t action_ref = tag_ptr(&obj->handle_error.action, false);
2410         return action_ref;
2411 }
2412 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint64_t ptr) {
2413         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2414         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2415                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2416                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
2417         return node_id_arr;
2418 }
2419 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint64_t ptr) {
2420         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2421         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2422                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2423                         uint64_t msg_ref = 0;
2424                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2425                         msg_ref = tag_ptr(msg_var.inner, false);
2426         return msg_ref;
2427 }
2428 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint64_t ptr) {
2429         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2430         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2431                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2432                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
2433         return node_id_arr;
2434 }
2435 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint64_t ptr) {
2436         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2437         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2438                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2439                         uint64_t msg_ref = 0;
2440                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2441                         msg_ref = tag_ptr(msg_var.inner, false);
2442         return msg_ref;
2443 }
2444 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint64_t ptr) {
2445         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2446         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2447                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2448                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
2449         return node_id_arr;
2450 }
2451 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint64_t ptr) {
2452         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2453         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2454                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2455                         uint64_t msg_ref = 0;
2456                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2457                         msg_ref = tag_ptr(msg_var.inner, false);
2458         return msg_ref;
2459 }
2460 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id(uint64_t ptr) {
2461         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2462         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2463                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2464                         memcpy(node_id_arr->elems, obj->send_gossip_timestamp_filter.node_id.compressed_form, 33);
2465         return node_id_arr;
2466 }
2467 uint64_t __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg(uint64_t ptr) {
2468         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
2469         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2470                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
2471                         uint64_t msg_ref = 0;
2472                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2473                         msg_ref = tag_ptr(msg_var.inner, false);
2474         return msg_ref;
2475 }
2476 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2477         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2478         for (size_t i = 0; i < ret.datalen; i++) {
2479                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2480         }
2481         return ret;
2482 }
2483 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2484 CHECK(owner->result_ok);
2485         return TxOut_clone(&*owner->contents.result);
2486 }
2487 uint64_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint64_t owner) {
2488         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(owner);
2489         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
2490         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
2491         return tag_ptr(ret_ref, true);
2492 }
2493
2494 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2495 CHECK(!owner->result_ok);
2496         return AccessError_clone(&*owner->contents.err);
2497 }
2498 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint64_t owner) {
2499         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(owner);
2500         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
2501         return ret_conv;
2502 }
2503
2504 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2505         return owner->a;
2506 }
2507 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint64_t owner) {
2508         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
2509         uint32_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
2510         return ret_conv;
2511 }
2512
2513 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2514         return owner->b;
2515 }
2516 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint64_t owner) {
2517         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
2518         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
2519         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2520         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2521         return ret_arr;
2522 }
2523
2524 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
2525         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
2526         for (size_t i = 0; i < ret.datalen; i++) {
2527                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
2528         }
2529         return ret;
2530 }
2531 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
2532         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
2533         for (size_t i = 0; i < ret.datalen; i++) {
2534                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
2535         }
2536         return ret;
2537 }
2538 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
2539 CHECK(owner->result_ok);
2540         return *owner->contents.result;
2541 }
2542 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint64_t owner) {
2543         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(owner);
2544         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
2545 }
2546
2547 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
2548 CHECK(!owner->result_ok);
2549         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
2550 }
2551 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint64_t owner) {
2552         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(owner);
2553         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
2554         return ret_conv;
2555 }
2556
2557 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint64_t ptr) {
2558         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
2559         switch(obj->tag) {
2560                 case LDKMonitorEvent_HTLCEvent: return 0;
2561                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
2562                 case LDKMonitorEvent_UpdateCompleted: return 2;
2563                 case LDKMonitorEvent_UpdateFailed: return 3;
2564                 default: abort();
2565         }
2566 }
2567 uint64_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint64_t ptr) {
2568         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
2569         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
2570                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
2571                         uint64_t htlc_event_ref = 0;
2572                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
2573                         htlc_event_ref = tag_ptr(htlc_event_var.inner, false);
2574         return htlc_event_ref;
2575 }
2576 uint64_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint64_t ptr) {
2577         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
2578         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
2579                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
2580                         uint64_t commitment_tx_confirmed_ref = 0;
2581                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
2582                         commitment_tx_confirmed_ref = tag_ptr(commitment_tx_confirmed_var.inner, false);
2583         return commitment_tx_confirmed_ref;
2584 }
2585 uint64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint64_t ptr) {
2586         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
2587         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
2588                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
2589                         uint64_t funding_txo_ref = 0;
2590                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2591                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
2592         return funding_txo_ref;
2593 }
2594 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint64_t ptr) {
2595         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
2596         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
2597                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
2598         return monitor_update_id_conv;
2599 }
2600 uint64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint64_t ptr) {
2601         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
2602         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
2603                         LDKOutPoint update_failed_var = obj->update_failed;
2604                         uint64_t update_failed_ref = 0;
2605                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
2606                         update_failed_ref = tag_ptr(update_failed_var.inner, false);
2607         return update_failed_ref;
2608 }
2609 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
2610         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
2611         for (size_t i = 0; i < ret.datalen; i++) {
2612                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
2613         }
2614         return ret;
2615 }
2616 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2617         LDKOutPoint ret = owner->a;
2618         ret.is_owned = false;
2619         return ret;
2620 }
2621 uint64_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(uint64_t owner) {
2622         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
2623         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
2624         uint64_t ret_ref = 0;
2625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2626         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2627         return ret_ref;
2628 }
2629
2630 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2631         return CVec_MonitorEventZ_clone(&owner->b);
2632 }
2633 uint64_tArray  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(uint64_t owner) {
2634         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
2635         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
2636         uint64_tArray ret_arr = NULL;
2637         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
2638         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
2639         for (size_t o = 0; o < ret_var.datalen; o++) {
2640                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2641                 *ret_conv_14_copy = ret_var.data[o];
2642                 uint64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
2643                 ret_arr_ptr[o] = ret_conv_14_ref;
2644         }
2645         
2646         FREE(ret_var.data);
2647         return ret_arr;
2648 }
2649
2650 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2651         return owner->c;
2652 }
2653 int8_tArray  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(uint64_t owner) {
2654         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
2655         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
2656         memcpy(ret_arr->elems, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form, 33);
2657         return ret_arr;
2658 }
2659
2660 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
2661         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
2662         for (size_t i = 0; i < ret.datalen; i++) {
2663                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
2664         }
2665         return ret;
2666 }
2667 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2668         LDKFixedPenaltyScorer ret = *owner->contents.result;
2669         ret.is_owned = false;
2670         return ret;
2671 }
2672 uint64_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(uint64_t owner) {
2673         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
2674         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
2675         uint64_t ret_ref = 0;
2676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2677         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2678         return ret_ref;
2679 }
2680
2681 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2682         LDKDecodeError ret = *owner->contents.err;
2683         ret.is_owned = false;
2684         return ret;
2685 }
2686 uint64_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(uint64_t owner) {
2687         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
2688         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
2689         uint64_t ret_ref = 0;
2690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2691         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2692         return ret_ref;
2693 }
2694
2695 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
2696         return owner->a;
2697 }
2698 int64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_get_a"))) TS_C2Tuple_u64u64Z_get_a(uint64_t owner) {
2699         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
2700         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
2701         return ret_conv;
2702 }
2703
2704 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
2705         return owner->b;
2706 }
2707 int64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_get_b"))) TS_C2Tuple_u64u64Z_get_b(uint64_t owner) {
2708         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
2709         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
2710         return ret_conv;
2711 }
2712
2713 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_u64u64ZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_u64u64ZZ_ty_from_ptr(uint64_t ptr) {
2714         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
2715         switch(obj->tag) {
2716                 case LDKCOption_C2Tuple_u64u64ZZ_Some: return 0;
2717                 case LDKCOption_C2Tuple_u64u64ZZ_None: return 1;
2718                 default: abort();
2719         }
2720 }
2721 uint64_t __attribute__((export_name("TS_LDKCOption_C2Tuple_u64u64ZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_u64u64ZZ_Some_get_some(uint64_t ptr) {
2722         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
2723         assert(obj->tag == LDKCOption_C2Tuple_u64u64ZZ_Some);
2724                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
2725                         *some_conv = obj->some;
2726                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
2727         return tag_ptr(some_conv, true);
2728 }
2729 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
2730         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
2731         for (size_t i = 0; i < ret.datalen; i++) {
2732                 ret.data[i] = NodeId_clone(&orig->data[i]);
2733         }
2734         return ret;
2735 }
2736 typedef struct LDKLogger_JCalls {
2737         atomic_size_t refcnt;
2738         uint32_t instance_ptr;
2739 } LDKLogger_JCalls;
2740 static void LDKLogger_JCalls_free(void* this_arg) {
2741         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2742         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2743                 FREE(j_calls);
2744         }
2745 }
2746 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
2747         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2748         LDKRecord record_var = *record;
2749         uint64_t record_ref = 0;
2750         record_var = Record_clone(&record_var);
2751         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
2752         record_ref = tag_ptr(record_var.inner, record_var.is_owned);
2753         js_invoke_function_buuuuu(j_calls->instance_ptr, 0, record_ref, 0, 0, 0, 0, 0);
2754 }
2755 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
2756         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
2757         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2758 }
2759 static inline LDKLogger LDKLogger_init (JSValue o) {
2760         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2761         atomic_init(&calls->refcnt, 1);
2762         calls->instance_ptr = o;
2763
2764         LDKLogger ret = {
2765                 .this_arg = (void*) calls,
2766                 .log = log_LDKLogger_jcall,
2767                 .free = LDKLogger_JCalls_free,
2768         };
2769         return ret;
2770 }
2771 uint64_t  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
2772         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2773         *res_ptr = LDKLogger_init(o);
2774         return tag_ptr(res_ptr, true);
2775 }
2776 static inline struct LDKProbabilisticScorer CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2777         LDKProbabilisticScorer ret = *owner->contents.result;
2778         ret.is_owned = false;
2779         return ret;
2780 }
2781 uint64_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok(uint64_t owner) {
2782         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
2783         LDKProbabilisticScorer ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
2784         uint64_t ret_ref = 0;
2785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2786         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2787         return ret_ref;
2788 }
2789
2790 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2791         LDKDecodeError ret = *owner->contents.err;
2792         ret.is_owned = false;
2793         return ret;
2794 }
2795 uint64_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err(uint64_t owner) {
2796         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
2797         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
2798         uint64_t ret_ref = 0;
2799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2800         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2801         return ret_ref;
2802 }
2803
2804 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2805         LDKInitFeatures ret = *owner->contents.result;
2806         ret.is_owned = false;
2807         return ret;
2808 }
2809 uint64_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint64_t owner) {
2810         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
2811         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
2812         uint64_t ret_ref = 0;
2813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2814         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2815         return ret_ref;
2816 }
2817
2818 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2819         LDKDecodeError ret = *owner->contents.err;
2820         ret.is_owned = false;
2821         return ret;
2822 }
2823 uint64_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint64_t owner) {
2824         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
2825         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
2826         uint64_t ret_ref = 0;
2827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2828         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2829         return ret_ref;
2830 }
2831
2832 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2833         LDKChannelFeatures ret = *owner->contents.result;
2834         ret.is_owned = false;
2835         return ret;
2836 }
2837 uint64_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint64_t owner) {
2838         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
2839         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
2840         uint64_t ret_ref = 0;
2841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2842         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2843         return ret_ref;
2844 }
2845
2846 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2847         LDKDecodeError ret = *owner->contents.err;
2848         ret.is_owned = false;
2849         return ret;
2850 }
2851 uint64_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint64_t owner) {
2852         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
2853         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
2854         uint64_t ret_ref = 0;
2855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2856         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2857         return ret_ref;
2858 }
2859
2860 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2861         LDKNodeFeatures ret = *owner->contents.result;
2862         ret.is_owned = false;
2863         return ret;
2864 }
2865 uint64_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint64_t owner) {
2866         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
2867         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
2868         uint64_t ret_ref = 0;
2869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2870         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2871         return ret_ref;
2872 }
2873
2874 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2875         LDKDecodeError ret = *owner->contents.err;
2876         ret.is_owned = false;
2877         return ret;
2878 }
2879 uint64_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint64_t owner) {
2880         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
2881         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
2882         uint64_t ret_ref = 0;
2883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2884         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2885         return ret_ref;
2886 }
2887
2888 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2889         LDKInvoiceFeatures ret = *owner->contents.result;
2890         ret.is_owned = false;
2891         return ret;
2892 }
2893 uint64_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint64_t owner) {
2894         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
2895         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
2896         uint64_t ret_ref = 0;
2897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2899         return ret_ref;
2900 }
2901
2902 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2903         LDKDecodeError ret = *owner->contents.err;
2904         ret.is_owned = false;
2905         return ret;
2906 }
2907 uint64_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint64_t owner) {
2908         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
2909         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
2910         uint64_t ret_ref = 0;
2911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2912         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2913         return ret_ref;
2914 }
2915
2916 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2917         LDKChannelTypeFeatures ret = *owner->contents.result;
2918         ret.is_owned = false;
2919         return ret;
2920 }
2921 uint64_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint64_t owner) {
2922         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
2923         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
2924         uint64_t ret_ref = 0;
2925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2926         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2927         return ret_ref;
2928 }
2929
2930 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2931         LDKDecodeError ret = *owner->contents.err;
2932         ret.is_owned = false;
2933         return ret;
2934 }
2935 uint64_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint64_t owner) {
2936         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
2937         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
2938         uint64_t ret_ref = 0;
2939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2940         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2941         return ret_ref;
2942 }
2943
2944 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
2945         LDKNodeId ret = *owner->contents.result;
2946         ret.is_owned = false;
2947         return ret;
2948 }
2949 uint64_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint64_t owner) {
2950         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
2951         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
2952         uint64_t ret_ref = 0;
2953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2954         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2955         return ret_ref;
2956 }
2957
2958 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
2959         LDKDecodeError ret = *owner->contents.err;
2960         ret.is_owned = false;
2961         return ret;
2962 }
2963 uint64_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint64_t owner) {
2964         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
2965         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
2966         uint64_t ret_ref = 0;
2967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2968         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2969         return ret_ref;
2970 }
2971
2972 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
2973 CHECK(owner->result_ok);
2974         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
2975 }
2976 uint64_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint64_t owner) {
2977         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
2978         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
2979         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
2980         uint64_t ret_ref = tag_ptr(ret_copy, true);
2981         return ret_ref;
2982 }
2983
2984 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
2985         LDKDecodeError ret = *owner->contents.err;
2986         ret.is_owned = false;
2987         return ret;
2988 }
2989 uint64_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint64_t owner) {
2990         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
2991         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
2992         uint64_t ret_ref = 0;
2993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2994         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2995         return ret_ref;
2996 }
2997
2998 typedef struct LDKAccess_JCalls {
2999         atomic_size_t refcnt;
3000         uint32_t instance_ptr;
3001 } LDKAccess_JCalls;
3002 static void LDKAccess_JCalls_free(void* this_arg) {
3003         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3004         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3005                 FREE(j_calls);
3006         }
3007 }
3008 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3009         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3010         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
3011         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
3012         int64_t short_channel_id_conv = short_channel_id;
3013         uint64_t ret = js_invoke_function_ubuuuu(j_calls->instance_ptr, 1, (uint32_t)genesis_hash_arr, short_channel_id_conv, 0, 0, 0, 0);
3014         void* ret_ptr = untag_ptr(ret);
3015         CHECK_ACCESS(ret_ptr);
3016         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
3017         FREE(untag_ptr(ret));
3018         return ret_conv;
3019 }
3020 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
3021         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
3022         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3023 }
3024 static inline LDKAccess LDKAccess_init (JSValue o) {
3025         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3026         atomic_init(&calls->refcnt, 1);
3027         calls->instance_ptr = o;
3028
3029         LDKAccess ret = {
3030                 .this_arg = (void*) calls,
3031                 .get_utxo = get_utxo_LDKAccess_jcall,
3032                 .free = LDKAccess_JCalls_free,
3033         };
3034         return ret;
3035 }
3036 uint64_t  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
3037         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3038         *res_ptr = LDKAccess_init(o);
3039         return tag_ptr(res_ptr, true);
3040 }
3041 uint64_t  __attribute__((export_name("TS_Access_get_utxo"))) TS_Access_get_utxo(uint64_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
3042         void* this_arg_ptr = untag_ptr(this_arg);
3043         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
3044         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3045         unsigned char genesis_hash_arr[32];
3046         CHECK(genesis_hash->arr_len == 32);
3047         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
3048         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3049         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3050         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3051         return tag_ptr(ret_conv, true);
3052 }
3053
3054 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint64_t ptr) {
3055         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)untag_ptr(ptr);
3056         switch(obj->tag) {
3057                 case LDKCOption_AccessZ_Some: return 0;
3058                 case LDKCOption_AccessZ_None: return 1;
3059                 default: abort();
3060         }
3061 }
3062 uint64_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint64_t ptr) {
3063         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)untag_ptr(ptr);
3064         assert(obj->tag == LDKCOption_AccessZ_Some);
3065                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
3066                         *some_ret = obj->some;
3067                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
3068                         if ((*some_ret).free == LDKAccess_JCalls_free) {
3069                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
3070                                 LDKAccess_JCalls_cloned(&(*some_ret));
3071                         }
3072         return tag_ptr(some_ret, true);
3073 }
3074 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3075 CHECK(owner->result_ok);
3076         return *owner->contents.result;
3077 }
3078 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint64_t owner) {
3079         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
3080         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
3081         return ret_conv;
3082 }
3083
3084 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3085         LDKLightningError ret = *owner->contents.err;
3086         ret.is_owned = false;
3087         return ret;
3088 }
3089 uint64_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint64_t owner) {
3090         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
3091         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
3092         uint64_t ret_ref = 0;
3093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3094         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3095         return ret_ref;
3096 }
3097
3098 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3099         LDKChannelAnnouncement ret = owner->a;
3100         ret.is_owned = false;
3101         return ret;
3102 }
3103 uint64_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint64_t owner) {
3104         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
3105         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
3106         uint64_t ret_ref = 0;
3107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3108         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3109         return ret_ref;
3110 }
3111
3112 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3113         LDKChannelUpdate ret = owner->b;
3114         ret.is_owned = false;
3115         return ret;
3116 }
3117 uint64_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint64_t owner) {
3118         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
3119         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
3120         uint64_t ret_ref = 0;
3121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3122         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3123         return ret_ref;
3124 }
3125
3126 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3127         LDKChannelUpdate ret = owner->c;
3128         ret.is_owned = false;
3129         return ret;
3130 }
3131 uint64_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint64_t owner) {
3132         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
3133         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
3134         uint64_t ret_ref = 0;
3135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3136         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3137         return ret_ref;
3138 }
3139
3140 uint32_t __attribute__((export_name("TS_LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_ty_from_ptr"))) TS_LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_ty_from_ptr(uint64_t ptr) {
3141         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *obj = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(ptr);
3142         switch(obj->tag) {
3143                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some: return 0;
3144                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None: return 1;
3145                 default: abort();
3146         }
3147 }
3148 uint64_t __attribute__((export_name("TS_LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_get_some"))) TS_LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_get_some(uint64_t ptr) {
3149         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *obj = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(ptr);
3150         assert(obj->tag == LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some);
3151                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* some_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
3152                         *some_conv = obj->some;
3153                         *some_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(some_conv);
3154         return tag_ptr(some_conv, true);
3155 }
3156 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3157 CHECK(owner->result_ok);
3158         return *owner->contents.result;
3159 }
3160 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint64_t owner) {
3161         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
3162         CResult_NoneLightningErrorZ_get_ok(owner_conv);
3163 }
3164
3165 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3166         LDKLightningError ret = *owner->contents.err;
3167         ret.is_owned = false;
3168         return ret;
3169 }
3170 uint64_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint64_t owner) {
3171         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
3172         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
3173         uint64_t ret_ref = 0;
3174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3175         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3176         return ret_ref;
3177 }
3178
3179 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3180         LDKChannelUpdateInfo ret = *owner->contents.result;
3181         ret.is_owned = false;
3182         return ret;
3183 }
3184 uint64_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(uint64_t owner) {
3185         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
3186         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
3187         uint64_t ret_ref = 0;
3188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3189         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3190         return ret_ref;
3191 }
3192
3193 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3194         LDKDecodeError ret = *owner->contents.err;
3195         ret.is_owned = false;
3196         return ret;
3197 }
3198 uint64_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(uint64_t owner) {
3199         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
3200         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
3201         uint64_t ret_ref = 0;
3202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3203         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3204         return ret_ref;
3205 }
3206
3207 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3208         LDKChannelInfo ret = *owner->contents.result;
3209         ret.is_owned = false;
3210         return ret;
3211 }
3212 uint64_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint64_t owner) {
3213         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
3214         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
3215         uint64_t ret_ref = 0;
3216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3217         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3218         return ret_ref;
3219 }
3220
3221 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3222         LDKDecodeError ret = *owner->contents.err;
3223         ret.is_owned = false;
3224         return ret;
3225 }
3226 uint64_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint64_t owner) {
3227         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
3228         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
3229         uint64_t ret_ref = 0;
3230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3231         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3232         return ret_ref;
3233 }
3234
3235 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3236         LDKRoutingFees ret = *owner->contents.result;
3237         ret.is_owned = false;
3238         return ret;
3239 }
3240 uint64_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint64_t owner) {
3241         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
3242         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
3243         uint64_t ret_ref = 0;
3244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3245         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3246         return ret_ref;
3247 }
3248
3249 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3250         LDKDecodeError ret = *owner->contents.err;
3251         ret.is_owned = false;
3252         return ret;
3253 }
3254 uint64_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint64_t owner) {
3255         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
3256         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
3257         uint64_t ret_ref = 0;
3258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3260         return ret_ref;
3261 }
3262
3263 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint64_t ptr) {
3264         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
3265         switch(obj->tag) {
3266                 case LDKNetAddress_IPv4: return 0;
3267                 case LDKNetAddress_IPv6: return 1;
3268                 case LDKNetAddress_OnionV2: return 2;
3269                 case LDKNetAddress_OnionV3: return 3;
3270                 case LDKNetAddress_Hostname: return 4;
3271                 default: abort();
3272         }
3273 }
3274 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint64_t ptr) {
3275         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
3276         assert(obj->tag == LDKNetAddress_IPv4);
3277                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
3278                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3279         return addr_arr;
3280 }
3281 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint64_t ptr) {
3282         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
3283         assert(obj->tag == LDKNetAddress_IPv4);
3284                         int16_t port_conv = obj->i_pv4.port;
3285         return port_conv;
3286 }
3287 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint64_t ptr) {
3288         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
3289         assert(obj->tag == LDKNetAddress_IPv6);
3290                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
3291                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
3292         return addr_arr;
3293 }
3294 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint64_t ptr) {
3295         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
3296         assert(obj->tag == LDKNetAddress_IPv6);
3297                         int16_t port_conv = obj->i_pv6.port;
3298         return port_conv;
3299 }
3300 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint64_t ptr) {
3301         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
3302         assert(obj->tag == LDKNetAddress_OnionV2);
3303                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
3304                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
3305         return onion_v2_arr;
3306 }
3307 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint64_t ptr) {
3308         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
3309         assert(obj->tag == LDKNetAddress_OnionV3);
3310                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
3311                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
3312         return ed25519_pubkey_arr;
3313 }
3314 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint64_t ptr) {
3315         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
3316         assert(obj->tag == LDKNetAddress_OnionV3);
3317                         int16_t checksum_conv = obj->onion_v3.checksum;
3318         return checksum_conv;
3319 }
3320 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint64_t ptr) {
3321         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
3322         assert(obj->tag == LDKNetAddress_OnionV3);
3323                         int8_t version_conv = obj->onion_v3.version;
3324         return version_conv;
3325 }
3326 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint64_t ptr) {
3327         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
3328         assert(obj->tag == LDKNetAddress_OnionV3);
3329                         int16_t port_conv = obj->onion_v3.port;
3330         return port_conv;
3331 }
3332 uint64_t __attribute__((export_name("TS_LDKNetAddress_Hostname_get_hostname"))) TS_LDKNetAddress_Hostname_get_hostname(uint64_t ptr) {
3333         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
3334         assert(obj->tag == LDKNetAddress_Hostname);
3335                         LDKHostname hostname_var = obj->hostname.hostname;
3336                         uint64_t hostname_ref = 0;
3337                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
3338                         hostname_ref = tag_ptr(hostname_var.inner, false);
3339         return hostname_ref;
3340 }
3341 int16_t __attribute__((export_name("TS_LDKNetAddress_Hostname_get_port"))) TS_LDKNetAddress_Hostname_get_port(uint64_t ptr) {
3342         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
3343         assert(obj->tag == LDKNetAddress_Hostname);
3344                         int16_t port_conv = obj->hostname.port;
3345         return port_conv;
3346 }
3347 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3348         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3349         for (size_t i = 0; i < ret.datalen; i++) {
3350                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3351         }
3352         return ret;
3353 }
3354 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3355         LDKNodeAnnouncementInfo ret = *owner->contents.result;
3356         ret.is_owned = false;
3357         return ret;
3358 }
3359 uint64_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint64_t owner) {
3360         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
3361         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
3362         uint64_t ret_ref = 0;
3363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3364         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3365         return ret_ref;
3366 }
3367
3368 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3369         LDKDecodeError ret = *owner->contents.err;
3370         ret.is_owned = false;
3371         return ret;
3372 }
3373 uint64_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint64_t owner) {
3374         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
3375         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
3376         uint64_t ret_ref = 0;
3377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3378         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3379         return ret_ref;
3380 }
3381
3382 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
3383         LDKNodeAlias ret = *owner->contents.result;
3384         ret.is_owned = false;
3385         return ret;
3386 }
3387 uint64_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_get_ok"))) TS_CResult_NodeAliasDecodeErrorZ_get_ok(uint64_t owner) {
3388         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
3389         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
3390         uint64_t ret_ref = 0;
3391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3392         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3393         return ret_ref;
3394 }
3395
3396 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
3397         LDKDecodeError ret = *owner->contents.err;
3398         ret.is_owned = false;
3399         return ret;
3400 }
3401 uint64_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_get_err"))) TS_CResult_NodeAliasDecodeErrorZ_get_err(uint64_t owner) {
3402         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
3403         LDKDecodeError ret_var = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
3404         uint64_t ret_ref = 0;
3405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3406         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3407         return ret_ref;
3408 }
3409
3410 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3411         LDKNodeInfo ret = *owner->contents.result;
3412         ret.is_owned = false;
3413         return ret;
3414 }
3415 uint64_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint64_t owner) {
3416         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
3417         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
3418         uint64_t ret_ref = 0;
3419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3420         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3421         return ret_ref;
3422 }
3423
3424 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3425         LDKDecodeError ret = *owner->contents.err;
3426         ret.is_owned = false;
3427         return ret;
3428 }
3429 uint64_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint64_t owner) {
3430         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
3431         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
3432         uint64_t ret_ref = 0;
3433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3434         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3435         return ret_ref;
3436 }
3437
3438 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3439         LDKNetworkGraph ret = *owner->contents.result;
3440         ret.is_owned = false;
3441         return ret;
3442 }
3443 uint64_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint64_t owner) {
3444         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
3445         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
3446         uint64_t ret_ref = 0;
3447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3448         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3449         return ret_ref;
3450 }
3451
3452 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3453         LDKDecodeError ret = *owner->contents.err;
3454         ret.is_owned = false;
3455         return ret;
3456 }
3457 uint64_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint64_t owner) {
3458         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
3459         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
3460         uint64_t ret_ref = 0;
3461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3462         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3463         return ret_ref;
3464 }
3465
3466 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint64_t ptr) {
3467         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(ptr);
3468         switch(obj->tag) {
3469                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
3470                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
3471                 default: abort();
3472         }
3473 }
3474 uint64_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint64_t ptr) {
3475         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(ptr);
3476         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
3477                         LDKCVec_NetAddressZ some_var = obj->some;
3478                         uint64_tArray some_arr = NULL;
3479                         some_arr = init_uint64_tArray(some_var.datalen, __LINE__);
3480                         uint64_t *some_arr_ptr = (uint64_t*)(((uint8_t*)some_arr) + 8);
3481                         for (size_t m = 0; m < some_var.datalen; m++) {
3482                                 uint64_t some_conv_12_ref = tag_ptr(&some_var.data[m], false);
3483                                 some_arr_ptr[m] = some_conv_12_ref;
3484                         }
3485                         
3486         return some_arr;
3487 }
3488 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3489         LDKDelayedPaymentOutputDescriptor ret = *owner->contents.result;
3490         ret.is_owned = false;
3491         return ret;
3492 }
3493 uint64_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint64_t owner) {
3494         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
3495         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3496         uint64_t ret_ref = 0;
3497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3498         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3499         return ret_ref;
3500 }
3501
3502 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3503         LDKDecodeError ret = *owner->contents.err;
3504         ret.is_owned = false;
3505         return ret;
3506 }
3507 uint64_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint64_t owner) {
3508         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
3509         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3510         uint64_t ret_ref = 0;
3511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3512         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3513         return ret_ref;
3514 }
3515
3516 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3517         LDKStaticPaymentOutputDescriptor ret = *owner->contents.result;
3518         ret.is_owned = false;
3519         return ret;
3520 }
3521 uint64_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint64_t owner) {
3522         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
3523         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3524         uint64_t ret_ref = 0;
3525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3526         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3527         return ret_ref;
3528 }
3529
3530 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3531         LDKDecodeError ret = *owner->contents.err;
3532         ret.is_owned = false;
3533         return ret;
3534 }
3535 uint64_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint64_t owner) {
3536         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
3537         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3538         uint64_t ret_ref = 0;
3539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3540         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3541         return ret_ref;
3542 }
3543
3544 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3545 CHECK(owner->result_ok);
3546         return SpendableOutputDescriptor_clone(&*owner->contents.result);
3547 }
3548 uint64_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint64_t owner) {
3549         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
3550         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
3551         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3552         uint64_t ret_ref = tag_ptr(ret_copy, true);
3553         return ret_ref;
3554 }
3555
3556 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3557         LDKDecodeError ret = *owner->contents.err;
3558         ret.is_owned = false;
3559         return ret;
3560 }
3561 uint64_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint64_t owner) {
3562         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
3563         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3564         uint64_t ret_ref = 0;
3565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3566         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3567         return ret_ref;
3568 }
3569
3570 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
3571         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
3572         for (size_t i = 0; i < ret.datalen; i++) {
3573                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3574         }
3575         return ret;
3576 }
3577 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3578         return owner->a;
3579 }
3580 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint64_t owner) {
3581         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
3582         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3583         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
3584         return ret_arr;
3585 }
3586
3587 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3588         return owner->b;
3589 }
3590 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint64_t owner) {
3591         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
3592         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
3593         ptrArray ret_arr = NULL;
3594         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
3595         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
3596         for (size_t m = 0; m < ret_var.datalen; m++) {
3597                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
3598                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
3599                 ret_arr_ptr[m] = ret_conv_12_arr;
3600         }
3601         
3602         return ret_arr;
3603 }
3604
3605 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3606 CHECK(owner->result_ok);
3607         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
3608 }
3609 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint64_t owner) {
3610         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
3611         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3612         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
3613         return tag_ptr(ret_conv, true);
3614 }
3615
3616 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3617 CHECK(!owner->result_ok);
3618         return *owner->contents.err;
3619 }
3620 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint64_t owner) {
3621         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
3622         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
3623 }
3624
3625 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3626 CHECK(owner->result_ok);
3627         return *owner->contents.result;
3628 }
3629 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint64_t owner) {
3630         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
3631         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3632         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
3633         return ret_arr;
3634 }
3635
3636 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3637 CHECK(!owner->result_ok);
3638         return *owner->contents.err;
3639 }
3640 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint64_t owner) {
3641         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
3642         CResult_SignatureNoneZ_get_err(owner_conv);
3643 }
3644
3645 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3646         return owner->a;
3647 }
3648 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_a"))) TS_C2Tuple_SignatureSignatureZ_get_a(uint64_t owner) {
3649         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(owner);
3650         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3651         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form, 64);
3652         return ret_arr;
3653 }
3654
3655 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3656         return owner->b;
3657 }
3658 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_b"))) TS_C2Tuple_SignatureSignatureZ_get_b(uint64_t owner) {
3659         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(owner);
3660         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3661         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form, 64);
3662         return ret_arr;
3663 }
3664
3665 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3666 CHECK(owner->result_ok);
3667         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
3668 }
3669 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(uint64_t owner) {
3670         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(owner);
3671         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
3672         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
3673         return tag_ptr(ret_conv, true);
3674 }
3675
3676 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3677 CHECK(!owner->result_ok);
3678         return *owner->contents.err;
3679 }
3680 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(uint64_t owner) {
3681         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(owner);
3682         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
3683 }
3684
3685 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3686 CHECK(owner->result_ok);
3687         return *owner->contents.result;
3688 }
3689 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_ok"))) TS_CResult_SecretKeyNoneZ_get_ok(uint64_t owner) {
3690         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(owner);
3691         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3692         memcpy(ret_arr->elems, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes, 32);
3693         return ret_arr;
3694 }
3695
3696 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3697 CHECK(!owner->result_ok);
3698         return *owner->contents.err;
3699 }
3700 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_err"))) TS_CResult_SecretKeyNoneZ_get_err(uint64_t owner) {
3701         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(owner);
3702         CResult_SecretKeyNoneZ_get_err(owner_conv);
3703 }
3704
3705 uint32_t __attribute__((export_name("TS_LDKCOption_ScalarZ_ty_from_ptr"))) TS_LDKCOption_ScalarZ_ty_from_ptr(uint64_t ptr) {
3706         LDKCOption_ScalarZ *obj = (LDKCOption_ScalarZ*)untag_ptr(ptr);
3707         switch(obj->tag) {
3708                 case LDKCOption_ScalarZ_Some: return 0;
3709                 case LDKCOption_ScalarZ_None: return 1;
3710                 default: abort();
3711         }
3712 }
3713 uint64_t __attribute__((export_name("TS_LDKCOption_ScalarZ_Some_get_some"))) TS_LDKCOption_ScalarZ_Some_get_some(uint64_t ptr) {
3714         LDKCOption_ScalarZ *obj = (LDKCOption_ScalarZ*)untag_ptr(ptr);
3715         assert(obj->tag == LDKCOption_ScalarZ_Some);
3716                         LDKBigEndianScalar* some_ref = &obj->some;
3717         return tag_ptr(some_ref, false);
3718 }
3719 static inline struct LDKThirtyTwoBytes CResult_SharedSecretNoneZ_get_ok(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
3720 CHECK(owner->result_ok);
3721         return ThirtyTwoBytes_clone(&*owner->contents.result);
3722 }
3723 int8_tArray  __attribute__((export_name("TS_CResult_SharedSecretNoneZ_get_ok"))) TS_CResult_SharedSecretNoneZ_get_ok(uint64_t owner) {
3724         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
3725         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3726         memcpy(ret_arr->elems, CResult_SharedSecretNoneZ_get_ok(owner_conv).data, 32);
3727         return ret_arr;
3728 }
3729
3730 static inline void CResult_SharedSecretNoneZ_get_err(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
3731 CHECK(!owner->result_ok);
3732         return *owner->contents.err;
3733 }
3734 void  __attribute__((export_name("TS_CResult_SharedSecretNoneZ_get_err"))) TS_CResult_SharedSecretNoneZ_get_err(uint64_t owner) {
3735         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
3736         CResult_SharedSecretNoneZ_get_err(owner_conv);
3737 }
3738
3739 typedef struct LDKBaseSign_JCalls {
3740         atomic_size_t refcnt;
3741         uint32_t instance_ptr;
3742 } LDKBaseSign_JCalls;
3743 static void LDKBaseSign_JCalls_free(void* this_arg) {
3744         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3745         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3746                 FREE(j_calls);
3747         }
3748 }
3749 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3750         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3751         int64_t idx_conv = idx;
3752         int8_tArray ret = (int8_tArray)js_invoke_function_buuuuu(j_calls->instance_ptr, 2, idx_conv, 0, 0, 0, 0, 0);
3753         LDKPublicKey ret_ref;
3754         CHECK(ret->arr_len == 33);
3755         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
3756         return ret_ref;
3757 }
3758 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3759         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3760         int64_t idx_conv = idx;
3761         int8_tArray ret = (int8_tArray)js_invoke_function_buuuuu(j_calls->instance_ptr, 3, idx_conv, 0, 0, 0, 0, 0);
3762         LDKThirtyTwoBytes ret_ref;
3763         CHECK(ret->arr_len == 32);
3764         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3765         return ret_ref;
3766 }
3767 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
3768         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3769         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
3770         uint64_t holder_tx_ref = 0;
3771         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
3772         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
3773         holder_tx_ref = tag_ptr(holder_tx_var.inner, holder_tx_var.is_owned);
3774         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3775         ptrArray preimages_arr = NULL;
3776         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3777         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 8);
3778         for (size_t m = 0; m < preimages_var.datalen; m++) {
3779                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3780                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3781                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3782         }
3783         
3784         FREE(preimages_var.data);
3785         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 4, holder_tx_ref, (uint32_t)preimages_arr, 0, 0, 0, 0);
3786         void* ret_ptr = untag_ptr(ret);
3787         CHECK_ACCESS(ret_ptr);
3788         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3789         FREE(untag_ptr(ret));
3790         return ret_conv;
3791 }
3792 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3793         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3794         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 5, 0, 0, 0, 0, 0, 0);
3795         LDKThirtyTwoBytes ret_ref;
3796         CHECK(ret->arr_len == 32);
3797         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3798         return ret_ref;
3799 }
3800 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
3801         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3802         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3803         uint64_t commitment_tx_ref = 0;
3804         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
3805         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3806         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
3807         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3808         ptrArray preimages_arr = NULL;
3809         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3810         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 8);
3811         for (size_t m = 0; m < preimages_var.datalen; m++) {
3812                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3813                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3814                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3815         }
3816         
3817         FREE(preimages_var.data);
3818         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 6, commitment_tx_ref, (uint32_t)preimages_arr, 0, 0, 0, 0);
3819         void* ret_ptr = untag_ptr(ret);
3820         CHECK_ACCESS(ret_ptr);
3821         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3822         FREE(untag_ptr(ret));
3823         return ret_conv;
3824 }
3825 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3826         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3827         int64_t idx_conv = idx;
3828         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
3829         memcpy(secret_arr->elems, *secret, 32);
3830         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 7, idx_conv, (uint32_t)secret_arr, 0, 0, 0, 0);
3831         void* ret_ptr = untag_ptr(ret);
3832         CHECK_ACCESS(ret_ptr);
3833         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3834         FREE(untag_ptr(ret));
3835         return ret_conv;
3836 }
3837 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3838         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3839         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3840         uint64_t commitment_tx_ref = 0;
3841         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
3842         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3843         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
3844         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 8, commitment_tx_ref, 0, 0, 0, 0, 0);
3845         void* ret_ptr = untag_ptr(ret);
3846         CHECK_ACCESS(ret_ptr);
3847         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3848         FREE(untag_ptr(ret));
3849         return ret_conv;
3850 }
3851 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]) {
3852         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3853         LDKTransaction justice_tx_var = justice_tx;
3854         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3855         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3856         Transaction_free(justice_tx_var);
3857         uint32_t input_conv = input;
3858         int64_t amount_conv = amount;
3859         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3860         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3861         uint64_t ret = js_invoke_function_uubuuu(j_calls->instance_ptr, 9, (uint32_t)justice_tx_arr, input_conv, amount_conv, (uint32_t)per_commitment_key_arr, 0, 0);
3862         void* ret_ptr = untag_ptr(ret);
3863         CHECK_ACCESS(ret_ptr);
3864         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3865         FREE(untag_ptr(ret));
3866         return ret_conv;
3867 }
3868 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) {
3869         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3870         LDKTransaction justice_tx_var = justice_tx;
3871         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3872         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3873         Transaction_free(justice_tx_var);
3874         uint32_t input_conv = input;
3875         int64_t amount_conv = amount;
3876         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3877         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3878         LDKHTLCOutputInCommitment htlc_var = *htlc;
3879         uint64_t htlc_ref = 0;
3880         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3881         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3882         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
3883         uint64_t ret = js_invoke_function_uububu(j_calls->instance_ptr, 10, (uint32_t)justice_tx_arr, input_conv, amount_conv, (uint32_t)per_commitment_key_arr, htlc_ref, 0);
3884         void* ret_ptr = untag_ptr(ret);
3885         CHECK_ACCESS(ret_ptr);
3886         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3887         FREE(untag_ptr(ret));
3888         return ret_conv;
3889 }
3890 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) {
3891         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3892         LDKTransaction htlc_tx_var = htlc_tx;
3893         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
3894         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
3895         Transaction_free(htlc_tx_var);
3896         uint32_t input_conv = input;
3897         int64_t amount_conv = amount;
3898         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
3899         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
3900         LDKHTLCOutputInCommitment htlc_var = *htlc;
3901         uint64_t htlc_ref = 0;
3902         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3903         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3904         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
3905         uint64_t ret = js_invoke_function_uububu(j_calls->instance_ptr, 11, (uint32_t)htlc_tx_arr, input_conv, amount_conv, (uint32_t)per_commitment_point_arr, htlc_ref, 0);
3906         void* ret_ptr = untag_ptr(ret);
3907         CHECK_ACCESS(ret_ptr);
3908         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3909         FREE(untag_ptr(ret));
3910         return ret_conv;
3911 }
3912 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3913         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3914         LDKClosingTransaction closing_tx_var = *closing_tx;
3915         uint64_t closing_tx_ref = 0;
3916         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
3917         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3918         closing_tx_ref = tag_ptr(closing_tx_var.inner, closing_tx_var.is_owned);
3919         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 12, closing_tx_ref, 0, 0, 0, 0, 0);
3920         void* ret_ptr = untag_ptr(ret);
3921         CHECK_ACCESS(ret_ptr);
3922         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3923         FREE(untag_ptr(ret));
3924         return ret_conv;
3925 }
3926 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3927         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3928         LDKUnsignedChannelAnnouncement msg_var = *msg;
3929         uint64_t msg_ref = 0;
3930         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
3931         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3932         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
3933         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 13, msg_ref, 0, 0, 0, 0, 0);
3934         void* ret_ptr = untag_ptr(ret);
3935         CHECK_ACCESS(ret_ptr);
3936         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
3937         FREE(untag_ptr(ret));
3938         return ret_conv;
3939 }
3940 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3941         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3942         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3943         uint64_t channel_parameters_ref = 0;
3944         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
3945         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
3946         channel_parameters_ref = tag_ptr(channel_parameters_var.inner, channel_parameters_var.is_owned);
3947         js_invoke_function_buuuuu(j_calls->instance_ptr, 14, channel_parameters_ref, 0, 0, 0, 0, 0);
3948 }
3949 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
3950         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
3951         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3952 }
3953 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint64_t pubkeys) {
3954         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
3955         atomic_init(&calls->refcnt, 1);
3956         calls->instance_ptr = o;
3957
3958         LDKChannelPublicKeys pubkeys_conv;
3959         pubkeys_conv.inner = untag_ptr(pubkeys);
3960         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
3961         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3962
3963         LDKBaseSign ret = {
3964                 .this_arg = (void*) calls,
3965                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
3966                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
3967                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
3968                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
3969                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
3970                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
3971                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
3972                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
3973                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
3974                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
3975                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
3976                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
3977                 .ready_channel = ready_channel_LDKBaseSign_jcall,
3978                 .free = LDKBaseSign_JCalls_free,
3979                 .pubkeys = pubkeys_conv,
3980                 .set_pubkeys = NULL,
3981         };
3982         return ret;
3983 }
3984 uint64_t  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint64_t pubkeys) {
3985         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
3986         *res_ptr = LDKBaseSign_init(o, pubkeys);
3987         return tag_ptr(res_ptr, true);
3988 }
3989 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint64_t this_arg, int64_t idx) {
3990         void* this_arg_ptr = untag_ptr(this_arg);
3991         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
3992         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3993         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
3994         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
3995         return ret_arr;
3996 }
3997
3998 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint64_t this_arg, int64_t idx) {
3999         void* this_arg_ptr = untag_ptr(this_arg);
4000         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4001         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4002         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4003         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
4004         return ret_arr;
4005 }
4006
4007 uint64_t  __attribute__((export_name("TS_BaseSign_validate_holder_commitment"))) TS_BaseSign_validate_holder_commitment(uint64_t this_arg, uint64_t holder_tx, ptrArray preimages) {
4008         void* this_arg_ptr = untag_ptr(this_arg);
4009         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4010         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4011         LDKHolderCommitmentTransaction holder_tx_conv;
4012         holder_tx_conv.inner = untag_ptr(holder_tx);
4013         holder_tx_conv.is_owned = ptr_is_owned(holder_tx);
4014         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
4015         holder_tx_conv.is_owned = false;
4016         LDKCVec_PaymentPreimageZ preimages_constr;
4017         preimages_constr.datalen = preimages->arr_len;
4018         if (preimages_constr.datalen > 0)
4019                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4020         else
4021                 preimages_constr.data = NULL;
4022         int8_tArray* preimages_vals = (void*) preimages->elems;
4023         for (size_t m = 0; m < preimages_constr.datalen; m++) {
4024                 int8_tArray preimages_conv_12 = preimages_vals[m];
4025                 LDKThirtyTwoBytes preimages_conv_12_ref;
4026                 CHECK(preimages_conv_12->arr_len == 32);
4027                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
4028                 preimages_constr.data[m] = preimages_conv_12_ref;
4029         }
4030         FREE(preimages);
4031         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4032         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
4033         return tag_ptr(ret_conv, true);
4034 }
4035
4036 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint64_t this_arg) {
4037         void* this_arg_ptr = untag_ptr(this_arg);
4038         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4039         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4040         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4041         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
4042         return ret_arr;
4043 }
4044
4045 uint64_t  __attribute__((export_name("TS_BaseSign_sign_counterparty_commitment"))) TS_BaseSign_sign_counterparty_commitment(uint64_t this_arg, uint64_t commitment_tx, ptrArray preimages) {
4046         void* this_arg_ptr = untag_ptr(this_arg);
4047         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4048         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4049         LDKCommitmentTransaction commitment_tx_conv;
4050         commitment_tx_conv.inner = untag_ptr(commitment_tx);
4051         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
4052         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4053         commitment_tx_conv.is_owned = false;
4054         LDKCVec_PaymentPreimageZ preimages_constr;
4055         preimages_constr.datalen = preimages->arr_len;
4056         if (preimages_constr.datalen > 0)
4057                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4058         else
4059                 preimages_constr.data = NULL;
4060         int8_tArray* preimages_vals = (void*) preimages->elems;
4061         for (size_t m = 0; m < preimages_constr.datalen; m++) {
4062                 int8_tArray preimages_conv_12 = preimages_vals[m];
4063                 LDKThirtyTwoBytes preimages_conv_12_ref;
4064                 CHECK(preimages_conv_12->arr_len == 32);
4065                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
4066                 preimages_constr.data[m] = preimages_conv_12_ref;
4067         }
4068         FREE(preimages);
4069         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4070         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
4071         return tag_ptr(ret_conv, true);
4072 }
4073
4074 uint64_t  __attribute__((export_name("TS_BaseSign_validate_counterparty_revocation"))) TS_BaseSign_validate_counterparty_revocation(uint64_t this_arg, int64_t idx, int8_tArray secret) {
4075         void* this_arg_ptr = untag_ptr(this_arg);
4076         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4077         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4078         unsigned char secret_arr[32];
4079         CHECK(secret->arr_len == 32);
4080         memcpy(secret_arr, secret->elems, 32); FREE(secret);
4081         unsigned char (*secret_ref)[32] = &secret_arr;
4082         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4083         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
4084         return tag_ptr(ret_conv, true);
4085 }
4086
4087 uint64_t  __attribute__((export_name("TS_BaseSign_sign_holder_commitment_and_htlcs"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint64_t this_arg, uint64_t commitment_tx) {
4088         void* this_arg_ptr = untag_ptr(this_arg);
4089         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4090         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4091         LDKHolderCommitmentTransaction commitment_tx_conv;
4092         commitment_tx_conv.inner = untag_ptr(commitment_tx);
4093         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
4094         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4095         commitment_tx_conv.is_owned = false;
4096         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4097         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
4098         return tag_ptr(ret_conv, true);
4099 }
4100
4101 uint64_t  __attribute__((export_name("TS_BaseSign_sign_justice_revoked_output"))) TS_BaseSign_sign_justice_revoked_output(uint64_t this_arg, int8_tArray justice_tx, uint32_t input, int64_t amount, int8_tArray per_commitment_key) {
4102         void* this_arg_ptr = untag_ptr(this_arg);
4103         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4104         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4105         LDKTransaction justice_tx_ref;
4106         justice_tx_ref.datalen = justice_tx->arr_len;
4107         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4108         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
4109         justice_tx_ref.data_is_owned = true;
4110         unsigned char per_commitment_key_arr[32];
4111         CHECK(per_commitment_key->arr_len == 32);
4112         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
4113         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4114         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4115         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
4116         return tag_ptr(ret_conv, true);
4117 }
4118
4119 uint64_t  __attribute__((export_name("TS_BaseSign_sign_justice_revoked_htlc"))) TS_BaseSign_sign_justice_revoked_htlc(uint64_t this_arg, int8_tArray justice_tx, uint32_t input, int64_t amount, int8_tArray per_commitment_key, uint64_t htlc) {
4120         void* this_arg_ptr = untag_ptr(this_arg);
4121         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4122         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4123         LDKTransaction justice_tx_ref;
4124         justice_tx_ref.datalen = justice_tx->arr_len;
4125         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4126         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
4127         justice_tx_ref.data_is_owned = true;
4128         unsigned char per_commitment_key_arr[32];
4129         CHECK(per_commitment_key->arr_len == 32);
4130         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
4131         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4132         LDKHTLCOutputInCommitment htlc_conv;
4133         htlc_conv.inner = untag_ptr(htlc);
4134         htlc_conv.is_owned = ptr_is_owned(htlc);
4135         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4136         htlc_conv.is_owned = false;
4137         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4138         *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);
4139         return tag_ptr(ret_conv, true);
4140 }
4141
4142 uint64_t  __attribute__((export_name("TS_BaseSign_sign_counterparty_htlc_transaction"))) TS_BaseSign_sign_counterparty_htlc_transaction(uint64_t this_arg, int8_tArray htlc_tx, uint32_t input, int64_t amount, int8_tArray per_commitment_point, uint64_t htlc) {
4143         void* this_arg_ptr = untag_ptr(this_arg);
4144         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4145         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4146         LDKTransaction htlc_tx_ref;
4147         htlc_tx_ref.datalen = htlc_tx->arr_len;
4148         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
4149         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
4150         htlc_tx_ref.data_is_owned = true;
4151         LDKPublicKey per_commitment_point_ref;
4152         CHECK(per_commitment_point->arr_len == 33);
4153         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
4154         LDKHTLCOutputInCommitment htlc_conv;
4155         htlc_conv.inner = untag_ptr(htlc);
4156         htlc_conv.is_owned = ptr_is_owned(htlc);
4157         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4158         htlc_conv.is_owned = false;
4159         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4160         *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);
4161         return tag_ptr(ret_conv, true);
4162 }
4163
4164 uint64_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint64_t this_arg, uint64_t closing_tx) {
4165         void* this_arg_ptr = untag_ptr(this_arg);
4166         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4167         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4168         LDKClosingTransaction closing_tx_conv;
4169         closing_tx_conv.inner = untag_ptr(closing_tx);
4170         closing_tx_conv.is_owned = ptr_is_owned(closing_tx);
4171         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
4172         closing_tx_conv.is_owned = false;
4173         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4174         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
4175         return tag_ptr(ret_conv, true);
4176 }
4177
4178 uint64_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint64_t this_arg, uint64_t msg) {
4179         void* this_arg_ptr = untag_ptr(this_arg);
4180         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4181         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4182         LDKUnsignedChannelAnnouncement msg_conv;
4183         msg_conv.inner = untag_ptr(msg);
4184         msg_conv.is_owned = ptr_is_owned(msg);
4185         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
4186         msg_conv.is_owned = false;
4187         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
4188         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4189         return tag_ptr(ret_conv, true);
4190 }
4191
4192 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint64_t this_arg, uint64_t channel_parameters) {
4193         void* this_arg_ptr = untag_ptr(this_arg);
4194         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4195         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4196         LDKChannelTransactionParameters channel_parameters_conv;
4197         channel_parameters_conv.inner = untag_ptr(channel_parameters);
4198         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
4199         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
4200         channel_parameters_conv.is_owned = false;
4201         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
4202 }
4203
4204 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
4205         if (this_arg->set_pubkeys != NULL)
4206                 this_arg->set_pubkeys(this_arg);
4207         return this_arg->pubkeys;
4208 }
4209 uint64_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint64_t this_arg) {
4210         void* this_arg_ptr = untag_ptr(this_arg);
4211         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4212         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4213         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
4214         uint64_t ret_ref = 0;
4215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4216         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4217         return ret_ref;
4218 }
4219
4220 typedef struct LDKSign_JCalls {
4221         atomic_size_t refcnt;
4222         uint32_t instance_ptr;
4223         LDKBaseSign_JCalls* BaseSign;
4224 } LDKSign_JCalls;
4225 static void LDKSign_JCalls_free(void* this_arg) {
4226         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4227         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4228                 FREE(j_calls);
4229         }
4230 }
4231 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
4232         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4233         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 15, 0, 0, 0, 0, 0, 0);
4234         LDKCVec_u8Z ret_ref;
4235         ret_ref.datalen = ret->arr_len;
4236         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4237         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4238         return ret_ref;
4239 }
4240 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
4241         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
4242         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4243         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
4244 }
4245 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint64_t pubkeys) {
4246         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
4247         atomic_init(&calls->refcnt, 1);
4248         calls->instance_ptr = o;
4249
4250         LDKChannelPublicKeys pubkeys_conv;
4251         pubkeys_conv.inner = untag_ptr(pubkeys);
4252         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
4253         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4254
4255         LDKSign ret = {
4256                 .this_arg = (void*) calls,
4257                 .write = write_LDKSign_jcall,
4258                 .cloned = LDKSign_JCalls_cloned,
4259                 .free = LDKSign_JCalls_free,
4260                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
4261         };
4262         calls->BaseSign = ret.BaseSign.this_arg;
4263         return ret;
4264 }
4265 uint64_t  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint64_t pubkeys) {
4266         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
4267         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
4268         return tag_ptr(res_ptr, true);
4269 }
4270 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint64_t this_arg) {
4271         void* this_arg_ptr = untag_ptr(this_arg);
4272         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4273         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
4274         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4275         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4276         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4277         CVec_u8Z_free(ret_var);
4278         return ret_arr;
4279 }
4280
4281 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4282 CHECK(owner->result_ok);
4283         return Sign_clone(&*owner->contents.result);
4284 }
4285 uint64_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint64_t owner) {
4286         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(owner);
4287         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4288         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
4289         return tag_ptr(ret_ret, true);
4290 }
4291
4292 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4293         LDKDecodeError ret = *owner->contents.err;
4294         ret.is_owned = false;
4295         return ret;
4296 }
4297 uint64_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint64_t owner) {
4298         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(owner);
4299         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
4300         uint64_t ret_ref = 0;
4301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4302         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4303         return ret_ref;
4304 }
4305
4306 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4307 CHECK(owner->result_ok);
4308         return *owner->contents.result;
4309 }
4310 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint64_t owner) {
4311         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
4312         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
4313         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
4314         return ret_arr;
4315 }
4316
4317 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4318 CHECK(!owner->result_ok);
4319         return *owner->contents.err;
4320 }
4321 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint64_t owner) {
4322         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
4323         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
4324 }
4325
4326 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
4327         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
4328         for (size_t i = 0; i < ret.datalen; i++) {
4329                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
4330         }
4331         return ret;
4332 }
4333 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4334 CHECK(owner->result_ok);
4335         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
4336 }
4337 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint64_t owner) {
4338         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
4339         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
4340         ptrArray ret_arr = NULL;
4341         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
4342         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
4343         for (size_t m = 0; m < ret_var.datalen; m++) {
4344                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
4345                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
4346                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
4347                 CVec_u8Z_free(ret_conv_12_var);
4348                 ret_arr_ptr[m] = ret_conv_12_arr;
4349         }
4350         
4351         FREE(ret_var.data);
4352         return ret_arr;
4353 }
4354
4355 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4356 CHECK(!owner->result_ok);
4357         return *owner->contents.err;
4358 }
4359 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint64_t owner) {
4360         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
4361         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
4362 }
4363
4364 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4365         LDKInMemorySigner ret = *owner->contents.result;
4366         ret.is_owned = false;
4367         return ret;
4368 }
4369 uint64_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint64_t owner) {
4370         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
4371         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
4372         uint64_t ret_ref = 0;
4373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4374         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4375         return ret_ref;
4376 }
4377
4378 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4379         LDKDecodeError ret = *owner->contents.err;
4380         ret.is_owned = false;
4381         return ret;
4382 }
4383 uint64_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint64_t owner) {
4384         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
4385         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
4386         uint64_t ret_ref = 0;
4387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4388         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4389         return ret_ref;
4390 }
4391
4392 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4393         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4394         for (size_t i = 0; i < ret.datalen; i++) {
4395                 ret.data[i] = TxOut_clone(&orig->data[i]);
4396         }
4397         return ret;
4398 }
4399 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4400 CHECK(owner->result_ok);
4401         return *owner->contents.result;
4402 }
4403 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint64_t owner) {
4404         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
4405         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
4406         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4407         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4408         return ret_arr;
4409 }
4410
4411 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4412 CHECK(!owner->result_ok);
4413         return *owner->contents.err;
4414 }
4415 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint64_t owner) {
4416         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
4417         CResult_TransactionNoneZ_get_err(owner_conv);
4418 }
4419
4420 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint64_t ptr) {
4421         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
4422         switch(obj->tag) {
4423                 case LDKCOption_u16Z_Some: return 0;
4424                 case LDKCOption_u16Z_None: return 1;
4425                 default: abort();
4426         }
4427 }
4428 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint64_t ptr) {
4429         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
4430         assert(obj->tag == LDKCOption_u16Z_Some);
4431                         int16_t some_conv = obj->some;
4432         return some_conv;
4433 }
4434 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint64_t ptr) {
4435         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
4436         switch(obj->tag) {
4437                 case LDKAPIError_APIMisuseError: return 0;
4438                 case LDKAPIError_FeeRateTooHigh: return 1;
4439                 case LDKAPIError_RouteError: return 2;
4440                 case LDKAPIError_ChannelUnavailable: return 3;
4441                 case LDKAPIError_MonitorUpdateFailed: return 4;
4442                 case LDKAPIError_IncompatibleShutdownScript: return 5;
4443                 default: abort();
4444         }
4445 }
4446 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint64_t ptr) {
4447         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
4448         assert(obj->tag == LDKAPIError_APIMisuseError);
4449                         LDKStr err_str = obj->api_misuse_error.err;
4450                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4451         return err_conv;
4452 }
4453 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint64_t ptr) {
4454         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
4455         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
4456                         LDKStr err_str = obj->fee_rate_too_high.err;
4457                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4458         return err_conv;
4459 }
4460 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint64_t ptr) {
4461         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
4462         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
4463                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
4464         return feerate_conv;
4465 }
4466 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint64_t ptr) {
4467         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
4468         assert(obj->tag == LDKAPIError_RouteError);
4469                         LDKStr err_str = obj->route_error.err;
4470                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4471         return err_conv;
4472 }
4473 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint64_t ptr) {
4474         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
4475         assert(obj->tag == LDKAPIError_ChannelUnavailable);
4476                         LDKStr err_str = obj->channel_unavailable.err;
4477                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4478         return err_conv;
4479 }
4480 uint64_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint64_t ptr) {
4481         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
4482         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
4483                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
4484                         uint64_t script_ref = 0;
4485                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
4486                         script_ref = tag_ptr(script_var.inner, false);
4487         return script_ref;
4488 }
4489 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4490 CHECK(owner->result_ok);
4491         return *owner->contents.result;
4492 }
4493 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint64_t owner) {
4494         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
4495         CResult_NoneAPIErrorZ_get_ok(owner_conv);
4496 }
4497
4498 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4499 CHECK(!owner->result_ok);
4500         return APIError_clone(&*owner->contents.err);
4501 }
4502 uint64_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint64_t owner) {
4503         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
4504         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4505         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
4506         uint64_t ret_ref = tag_ptr(ret_copy, true);
4507         return ret_ref;
4508 }
4509
4510 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4511         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4512         for (size_t i = 0; i < ret.datalen; i++) {
4513                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4514         }
4515         return ret;
4516 }
4517 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4518         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4519         for (size_t i = 0; i < ret.datalen; i++) {
4520                 ret.data[i] = APIError_clone(&orig->data[i]);
4521         }
4522         return ret;
4523 }
4524 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4525 CHECK(owner->result_ok);
4526         return ThirtyTwoBytes_clone(&*owner->contents.result);
4527 }
4528 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint64_t owner) {
4529         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
4530         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4531         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
4532         return ret_arr;
4533 }
4534
4535 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4536 CHECK(!owner->result_ok);
4537         return APIError_clone(&*owner->contents.err);
4538 }
4539 uint64_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint64_t owner) {
4540         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
4541         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4542         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
4543         uint64_t ret_ref = tag_ptr(ret_copy, true);
4544         return ret_ref;
4545 }
4546
4547 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint64_t ptr) {
4548         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
4549         switch(obj->tag) {
4550                 case LDKPaymentSendFailure_ParameterError: return 0;
4551                 case LDKPaymentSendFailure_PathParameterError: return 1;
4552                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
4553                 case LDKPaymentSendFailure_PartialFailure: return 3;
4554                 default: abort();
4555         }
4556 }
4557 uint64_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint64_t ptr) {
4558         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
4559         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
4560                         uint64_t parameter_error_ref = tag_ptr(&obj->parameter_error, false);
4561         return parameter_error_ref;
4562 }
4563 uint64_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint64_t ptr) {
4564         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
4565         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
4566                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
4567                         uint64_tArray path_parameter_error_arr = NULL;
4568                         path_parameter_error_arr = init_uint64_tArray(path_parameter_error_var.datalen, __LINE__);
4569                         uint64_t *path_parameter_error_arr_ptr = (uint64_t*)(((uint8_t*)path_parameter_error_arr) + 8);
4570                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
4571                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4572                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
4573                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
4574                                 path_parameter_error_arr_ptr[w] = tag_ptr(path_parameter_error_conv_22_conv, true);
4575                         }
4576                         
4577         return path_parameter_error_arr;
4578 }
4579 uint64_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint64_t ptr) {
4580         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
4581         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
4582                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
4583                         uint64_tArray all_failed_retry_safe_arr = NULL;
4584                         all_failed_retry_safe_arr = init_uint64_tArray(all_failed_retry_safe_var.datalen, __LINE__);
4585                         uint64_t *all_failed_retry_safe_arr_ptr = (uint64_t*)(((uint8_t*)all_failed_retry_safe_arr) + 8);
4586                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
4587                                 uint64_t all_failed_retry_safe_conv_10_ref = tag_ptr(&all_failed_retry_safe_var.data[k], false);
4588                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
4589                         }
4590                         
4591         return all_failed_retry_safe_arr;
4592 }
4593 uint64_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint64_t ptr) {
4594         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
4595         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4596                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
4597                         uint64_tArray results_arr = NULL;
4598                         results_arr = init_uint64_tArray(results_var.datalen, __LINE__);
4599                         uint64_t *results_arr_ptr = (uint64_t*)(((uint8_t*)results_arr) + 8);
4600                         for (size_t w = 0; w < results_var.datalen; w++) {
4601                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4602                                 *results_conv_22_conv = results_var.data[w];
4603                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
4604                                 results_arr_ptr[w] = tag_ptr(results_conv_22_conv, true);
4605                         }
4606                         
4607         return results_arr;
4608 }
4609 uint64_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint64_t ptr) {
4610         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
4611         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4612                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
4613                         uint64_t failed_paths_retry_ref = 0;
4614                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
4615                         failed_paths_retry_ref = tag_ptr(failed_paths_retry_var.inner, false);
4616         return failed_paths_retry_ref;
4617 }
4618 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint64_t ptr) {
4619         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
4620         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4621                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
4622                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
4623         return payment_id_arr;
4624 }
4625 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4626 CHECK(owner->result_ok);
4627         return ThirtyTwoBytes_clone(&*owner->contents.result);
4628 }
4629 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint64_t owner) {
4630         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(owner);
4631         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4632         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
4633         return ret_arr;
4634 }
4635
4636 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4637 CHECK(!owner->result_ok);
4638         return PaymentSendFailure_clone(&*owner->contents.err);
4639 }
4640 uint64_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint64_t owner) {
4641         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(owner);
4642         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4643         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
4644         uint64_t ret_ref = tag_ptr(ret_copy, true);
4645         return ret_ref;
4646 }
4647
4648 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4649 CHECK(owner->result_ok);
4650         return *owner->contents.result;
4651 }
4652 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint64_t owner) {
4653         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
4654         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
4655 }
4656
4657 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4658 CHECK(!owner->result_ok);
4659         return PaymentSendFailure_clone(&*owner->contents.err);
4660 }
4661 uint64_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint64_t owner) {
4662         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
4663         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4664         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
4665         uint64_t ret_ref = tag_ptr(ret_copy, true);
4666         return ret_ref;
4667 }
4668
4669 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4670         return ThirtyTwoBytes_clone(&owner->a);
4671 }
4672 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint64_t owner) {
4673         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
4674         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4675         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
4676         return ret_arr;
4677 }
4678
4679 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4680         return ThirtyTwoBytes_clone(&owner->b);
4681 }
4682 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint64_t owner) {
4683         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
4684         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4685         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
4686         return ret_arr;
4687 }
4688
4689 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4690 CHECK(owner->result_ok);
4691         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
4692 }
4693 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint64_t owner) {
4694         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
4695         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
4696         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
4697         return tag_ptr(ret_conv, true);
4698 }
4699
4700 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4701 CHECK(!owner->result_ok);
4702         return PaymentSendFailure_clone(&*owner->contents.err);
4703 }
4704 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint64_t owner) {
4705         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
4706         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4707         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
4708         uint64_t ret_ref = tag_ptr(ret_copy, true);
4709         return ret_ref;
4710 }
4711
4712 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
4713         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
4714         for (size_t i = 0; i < ret.datalen; i++) {
4715                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4716         }
4717         return ret;
4718 }
4719 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4720         return ThirtyTwoBytes_clone(&owner->a);
4721 }
4722 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint64_t owner) {
4723         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
4724         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4725         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
4726         return ret_arr;
4727 }
4728
4729 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4730         return ThirtyTwoBytes_clone(&owner->b);
4731 }
4732 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint64_t owner) {
4733         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
4734         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4735         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
4736         return ret_arr;
4737 }
4738
4739 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4740 CHECK(owner->result_ok);
4741         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4742 }
4743 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint64_t owner) {
4744         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
4745         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4746         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
4747         return tag_ptr(ret_conv, true);
4748 }
4749
4750 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4751 CHECK(!owner->result_ok);
4752         return *owner->contents.err;
4753 }
4754 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint64_t owner) {
4755         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
4756         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
4757 }
4758
4759 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4760 CHECK(owner->result_ok);
4761         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4762 }
4763 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint64_t owner) {
4764         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
4765         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4766         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
4767         return tag_ptr(ret_conv, true);
4768 }
4769
4770 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4771 CHECK(!owner->result_ok);
4772         return APIError_clone(&*owner->contents.err);
4773 }
4774 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint64_t owner) {
4775         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
4776         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4777         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
4778         uint64_t ret_ref = tag_ptr(ret_copy, true);
4779         return ret_ref;
4780 }
4781
4782 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4783 CHECK(owner->result_ok);
4784         return ThirtyTwoBytes_clone(&*owner->contents.result);
4785 }
4786 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint64_t owner) {
4787         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
4788         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4789         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
4790         return ret_arr;
4791 }
4792
4793 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4794 CHECK(!owner->result_ok);
4795         return *owner->contents.err;
4796 }
4797 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint64_t owner) {
4798         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
4799         CResult_PaymentSecretNoneZ_get_err(owner_conv);
4800 }
4801
4802 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4803 CHECK(owner->result_ok);
4804         return ThirtyTwoBytes_clone(&*owner->contents.result);
4805 }
4806 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint64_t owner) {
4807         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
4808         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4809         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
4810         return ret_arr;
4811 }
4812
4813 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4814 CHECK(!owner->result_ok);
4815         return APIError_clone(&*owner->contents.err);
4816 }
4817 uint64_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint64_t owner) {
4818         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
4819         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4820         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
4821         uint64_t ret_ref = tag_ptr(ret_copy, true);
4822         return ret_ref;
4823 }
4824
4825 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4826 CHECK(owner->result_ok);
4827         return ThirtyTwoBytes_clone(&*owner->contents.result);
4828 }
4829 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint64_t owner) {
4830         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
4831         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4832         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
4833         return ret_arr;
4834 }
4835
4836 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4837 CHECK(!owner->result_ok);
4838         return APIError_clone(&*owner->contents.err);
4839 }
4840 uint64_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint64_t owner) {
4841         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
4842         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4843         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
4844         uint64_t ret_ref = tag_ptr(ret_copy, true);
4845         return ret_ref;
4846 }
4847
4848 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4849         LDKCounterpartyForwardingInfo ret = *owner->contents.result;
4850         ret.is_owned = false;
4851         return ret;
4852 }
4853 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(uint64_t owner) {
4854         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
4855         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
4856         uint64_t ret_ref = 0;
4857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4858         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4859         return ret_ref;
4860 }
4861
4862 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4863         LDKDecodeError ret = *owner->contents.err;
4864         ret.is_owned = false;
4865         return ret;
4866 }
4867 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(uint64_t owner) {
4868         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
4869         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
4870         uint64_t ret_ref = 0;
4871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4872         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4873         return ret_ref;
4874 }
4875
4876 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4877         LDKChannelCounterparty ret = *owner->contents.result;
4878         ret.is_owned = false;
4879         return ret;
4880 }
4881 uint64_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(uint64_t owner) {
4882         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
4883         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
4884         uint64_t ret_ref = 0;
4885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4886         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4887         return ret_ref;
4888 }
4889
4890 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4891         LDKDecodeError ret = *owner->contents.err;
4892         ret.is_owned = false;
4893         return ret;
4894 }
4895 uint64_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err(uint64_t owner) {
4896         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
4897         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
4898         uint64_t ret_ref = 0;
4899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4900         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4901         return ret_ref;
4902 }
4903
4904 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4905         LDKChannelDetails ret = *owner->contents.result;
4906         ret.is_owned = false;
4907         return ret;
4908 }
4909 uint64_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_ok(uint64_t owner) {
4910         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
4911         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
4912         uint64_t ret_ref = 0;
4913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4914         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4915         return ret_ref;
4916 }
4917
4918 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4919         LDKDecodeError ret = *owner->contents.err;
4920         ret.is_owned = false;
4921         return ret;
4922 }
4923 uint64_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_err(uint64_t owner) {
4924         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
4925         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
4926         uint64_t ret_ref = 0;
4927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4928         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4929         return ret_ref;
4930 }
4931
4932 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4933         LDKPhantomRouteHints ret = *owner->contents.result;
4934         ret.is_owned = false;
4935         return ret;
4936 }
4937 uint64_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(uint64_t owner) {
4938         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
4939         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
4940         uint64_t ret_ref = 0;
4941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4942         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4943         return ret_ref;
4944 }
4945
4946 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4947         LDKDecodeError ret = *owner->contents.err;
4948         ret.is_owned = false;
4949         return ret;
4950 }
4951 uint64_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err(uint64_t owner) {
4952         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
4953         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
4954         uint64_t ret_ref = 0;
4955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4956         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4957         return ret_ref;
4958 }
4959
4960 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4961         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4962         for (size_t i = 0; i < ret.datalen; i++) {
4963                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4964         }
4965         return ret;
4966 }
4967 typedef struct LDKWatch_JCalls {
4968         atomic_size_t refcnt;
4969         uint32_t instance_ptr;
4970 } LDKWatch_JCalls;
4971 static void LDKWatch_JCalls_free(void* this_arg) {
4972         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4973         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4974                 FREE(j_calls);
4975         }
4976 }
4977 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4978         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4979         LDKOutPoint funding_txo_var = funding_txo;
4980         uint64_t funding_txo_ref = 0;
4981         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4982         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
4983         LDKChannelMonitor monitor_var = monitor;
4984         uint64_t monitor_ref = 0;
4985         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
4986         monitor_ref = tag_ptr(monitor_var.inner, monitor_var.is_owned);
4987         uint64_t ret = js_invoke_function_bbuuuu(j_calls->instance_ptr, 16, funding_txo_ref, monitor_ref, 0, 0, 0, 0);
4988         void* ret_ptr = untag_ptr(ret);
4989         CHECK_ACCESS(ret_ptr);
4990         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4991         FREE(untag_ptr(ret));
4992         return ret_conv;
4993 }
4994 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4995         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4996         LDKOutPoint funding_txo_var = funding_txo;
4997         uint64_t funding_txo_ref = 0;
4998         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4999         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
5000         LDKChannelMonitorUpdate update_var = update;
5001         uint64_t update_ref = 0;
5002         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5003         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
5004         uint64_t ret = js_invoke_function_bbuuuu(j_calls->instance_ptr, 17, funding_txo_ref, update_ref, 0, 0, 0, 0);
5005         void* ret_ptr = untag_ptr(ret);
5006         CHECK_ACCESS(ret_ptr);
5007         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5008         FREE(untag_ptr(ret));
5009         return ret_conv;
5010 }
5011 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5012         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5013         uint64_tArray ret = (uint64_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 18, 0, 0, 0, 0, 0, 0);
5014         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
5015         ret_constr.datalen = ret->arr_len;
5016         if (ret_constr.datalen > 0)
5017                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
5018         else
5019                 ret_constr.data = NULL;
5020         uint64_t* ret_vals = ret->elems;
5021         for (size_t x = 0; x < ret_constr.datalen; x++) {
5022                 uint64_t ret_conv_49 = ret_vals[x];
5023                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
5024                 CHECK_ACCESS(ret_conv_49_ptr);
5025                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
5026                 FREE(untag_ptr(ret_conv_49));
5027                 ret_constr.data[x] = ret_conv_49_conv;
5028         }
5029         FREE(ret);
5030         return ret_constr;
5031 }
5032 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5033         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5034         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5035 }
5036 static inline LDKWatch LDKWatch_init (JSValue o) {
5037         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
5038         atomic_init(&calls->refcnt, 1);
5039         calls->instance_ptr = o;
5040
5041         LDKWatch ret = {
5042                 .this_arg = (void*) calls,
5043                 .watch_channel = watch_channel_LDKWatch_jcall,
5044                 .update_channel = update_channel_LDKWatch_jcall,
5045                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5046                 .free = LDKWatch_JCalls_free,
5047         };
5048         return ret;
5049 }
5050 uint64_t  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
5051         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5052         *res_ptr = LDKWatch_init(o);
5053         return tag_ptr(res_ptr, true);
5054 }
5055 uint64_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint64_t this_arg, uint64_t funding_txo, uint64_t monitor) {
5056         void* this_arg_ptr = untag_ptr(this_arg);
5057         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5058         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5059         LDKOutPoint funding_txo_conv;
5060         funding_txo_conv.inner = untag_ptr(funding_txo);
5061         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
5062         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5063         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5064         LDKChannelMonitor monitor_conv;
5065         monitor_conv.inner = untag_ptr(monitor);
5066         monitor_conv.is_owned = ptr_is_owned(monitor);
5067         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5068         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5069         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5070         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5071         return tag_ptr(ret_conv, true);
5072 }
5073
5074 uint64_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint64_t this_arg, uint64_t funding_txo, uint64_t update) {
5075         void* this_arg_ptr = untag_ptr(this_arg);
5076         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5077         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5078         LDKOutPoint funding_txo_conv;
5079         funding_txo_conv.inner = untag_ptr(funding_txo);
5080         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
5081         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5082         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5083         LDKChannelMonitorUpdate update_conv;
5084         update_conv.inner = untag_ptr(update);
5085         update_conv.is_owned = ptr_is_owned(update);
5086         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5087         update_conv = ChannelMonitorUpdate_clone(&update_conv);
5088         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5089         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
5090         return tag_ptr(ret_conv, true);
5091 }
5092
5093 uint64_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint64_t this_arg) {
5094         void* this_arg_ptr = untag_ptr(this_arg);
5095         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5096         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5097         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
5098         uint64_tArray ret_arr = NULL;
5099         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
5100         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
5101         for (size_t x = 0; x < ret_var.datalen; x++) {
5102                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
5103                 *ret_conv_49_conv = ret_var.data[x];
5104                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
5105         }
5106         
5107         FREE(ret_var.data);
5108         return ret_arr;
5109 }
5110
5111 typedef struct LDKBroadcasterInterface_JCalls {
5112         atomic_size_t refcnt;
5113         uint32_t instance_ptr;
5114 } LDKBroadcasterInterface_JCalls;
5115 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
5116         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5117         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5118                 FREE(j_calls);
5119         }
5120 }
5121 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
5122         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5123         LDKTransaction tx_var = tx;
5124         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
5125         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
5126         Transaction_free(tx_var);
5127         js_invoke_function_uuuuuu(j_calls->instance_ptr, 19, (uint32_t)tx_arr, 0, 0, 0, 0, 0);
5128 }
5129 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
5130         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
5131         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5132 }
5133 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
5134         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
5135         atomic_init(&calls->refcnt, 1);
5136         calls->instance_ptr = o;
5137
5138         LDKBroadcasterInterface ret = {
5139                 .this_arg = (void*) calls,
5140                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
5141                 .free = LDKBroadcasterInterface_JCalls_free,
5142         };
5143         return ret;
5144 }
5145 uint64_t  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
5146         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
5147         *res_ptr = LDKBroadcasterInterface_init(o);
5148         return tag_ptr(res_ptr, true);
5149 }
5150 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint64_t this_arg, int8_tArray tx) {
5151         void* this_arg_ptr = untag_ptr(this_arg);
5152         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5153         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
5154         LDKTransaction tx_ref;
5155         tx_ref.datalen = tx->arr_len;
5156         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
5157         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
5158         tx_ref.data_is_owned = true;
5159         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
5160 }
5161
5162 typedef struct LDKKeysInterface_JCalls {
5163         atomic_size_t refcnt;
5164         uint32_t instance_ptr;
5165 } LDKKeysInterface_JCalls;
5166 static void LDKKeysInterface_JCalls_free(void* this_arg) {
5167         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5168         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5169                 FREE(j_calls);
5170         }
5171 }
5172 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
5173         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5174         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
5175         uint64_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 20, recipient_conv, 0, 0, 0, 0, 0);
5176         void* ret_ptr = untag_ptr(ret);
5177         CHECK_ACCESS(ret_ptr);
5178         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
5179         FREE(untag_ptr(ret));
5180         return ret_conv;
5181 }
5182 LDKCResult_SharedSecretNoneZ ecdh_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient, LDKPublicKey other_key, LDKCOption_ScalarZ tweak) {
5183         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5184         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
5185         int8_tArray other_key_arr = init_int8_tArray(33, __LINE__);
5186         memcpy(other_key_arr->elems, other_key.compressed_form, 33);
5187         LDKCOption_ScalarZ *tweak_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
5188         *tweak_copy = tweak;
5189         uint64_t tweak_ref = tag_ptr(tweak_copy, true);
5190         uint64_t ret = js_invoke_function_uubuuu(j_calls->instance_ptr, 21, recipient_conv, (uint32_t)other_key_arr, tweak_ref, 0, 0, 0);
5191         void* ret_ptr = untag_ptr(ret);
5192         CHECK_ACCESS(ret_ptr);
5193         LDKCResult_SharedSecretNoneZ ret_conv = *(LDKCResult_SharedSecretNoneZ*)(ret_ptr);
5194         FREE(untag_ptr(ret));
5195         return ret_conv;
5196 }
5197 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
5198         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5199         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 22, 0, 0, 0, 0, 0, 0);
5200         LDKCVec_u8Z ret_ref;
5201         ret_ref.datalen = ret->arr_len;
5202         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5203         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5204         return ret_ref;
5205 }
5206 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
5207         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5208         uint64_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 23, 0, 0, 0, 0, 0, 0);
5209         LDKShutdownScript ret_conv;
5210         ret_conv.inner = untag_ptr(ret);
5211         ret_conv.is_owned = ptr_is_owned(ret);
5212         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
5213         return ret_conv;
5214 }
5215 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
5216         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5217         jboolean inbound_conv = inbound;
5218         int64_t channel_value_satoshis_conv = channel_value_satoshis;
5219         uint64_t ret = js_invoke_function_ubuuuu(j_calls->instance_ptr, 24, inbound_conv, channel_value_satoshis_conv, 0, 0, 0, 0);
5220         void* ret_ptr = untag_ptr(ret);
5221         CHECK_ACCESS(ret_ptr);
5222         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
5223         FREE(untag_ptr(ret));
5224         return ret_conv;
5225 }
5226 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
5227         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5228         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 25, 0, 0, 0, 0, 0, 0);
5229         LDKThirtyTwoBytes ret_ref;
5230         CHECK(ret->arr_len == 32);
5231         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
5232         return ret_ref;
5233 }
5234 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
5235         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5236         LDKu8slice reader_var = reader;
5237         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
5238         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
5239         uint64_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 26, (uint32_t)reader_arr, 0, 0, 0, 0, 0);
5240         void* ret_ptr = untag_ptr(ret);
5241         CHECK_ACCESS(ret_ptr);
5242         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
5243         FREE(untag_ptr(ret));
5244         return ret_conv;
5245 }
5246 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
5247         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5248         LDKu8slice hrp_bytes_var = hrp_bytes;
5249         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
5250         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
5251         LDKCVec_u5Z invoice_data_var = invoice_data;
5252         ptrArray invoice_data_arr = NULL;
5253         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
5254         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 8);
5255         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
5256                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
5257                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
5258         }
5259         
5260         FREE(invoice_data_var.data);
5261         uint32_t receipient_conv = LDKRecipient_to_js(receipient);
5262         uint64_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 27, (uint32_t)hrp_bytes_arr, (uint32_t)invoice_data_arr, receipient_conv, 0, 0, 0);
5263         void* ret_ptr = untag_ptr(ret);
5264         CHECK_ACCESS(ret_ptr);
5265         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
5266         FREE(untag_ptr(ret));
5267         return ret_conv;
5268 }
5269 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
5270         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5271         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 28, 0, 0, 0, 0, 0, 0);
5272         LDKThirtyTwoBytes ret_ref;
5273         CHECK(ret->arr_len == 32);
5274         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
5275         return ret_ref;
5276 }
5277 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
5278         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
5279         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5280 }
5281 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
5282         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
5283         atomic_init(&calls->refcnt, 1);
5284         calls->instance_ptr = o;
5285
5286         LDKKeysInterface ret = {
5287                 .this_arg = (void*) calls,
5288                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
5289                 .ecdh = ecdh_LDKKeysInterface_jcall,
5290                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
5291                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
5292                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
5293                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
5294                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
5295                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
5296                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
5297                 .free = LDKKeysInterface_JCalls_free,
5298         };
5299         return ret;
5300 }
5301 uint64_t  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
5302         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
5303         *res_ptr = LDKKeysInterface_init(o);
5304         return tag_ptr(res_ptr, true);
5305 }
5306 uint64_t  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint64_t this_arg, uint32_t recipient) {
5307         void* this_arg_ptr = untag_ptr(this_arg);
5308         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5309         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5310         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
5311         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
5312         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
5313         return tag_ptr(ret_conv, true);
5314 }
5315
5316 uint64_t  __attribute__((export_name("TS_KeysInterface_ecdh"))) TS_KeysInterface_ecdh(uint64_t this_arg, uint32_t recipient, int8_tArray other_key, uint64_t tweak) {
5317         void* this_arg_ptr = untag_ptr(this_arg);
5318         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5319         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5320         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
5321         LDKPublicKey other_key_ref;
5322         CHECK(other_key->arr_len == 33);
5323         memcpy(other_key_ref.compressed_form, other_key->elems, 33); FREE(other_key);
5324         void* tweak_ptr = untag_ptr(tweak);
5325         CHECK_ACCESS(tweak_ptr);
5326         LDKCOption_ScalarZ tweak_conv = *(LDKCOption_ScalarZ*)(tweak_ptr);
5327         // WARNING: we may need a move here but no clone is available for LDKCOption_ScalarZ
5328         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
5329         *ret_conv = (this_arg_conv->ecdh)(this_arg_conv->this_arg, recipient_conv, other_key_ref, tweak_conv);
5330         return tag_ptr(ret_conv, true);
5331 }
5332
5333 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint64_t this_arg) {
5334         void* this_arg_ptr = untag_ptr(this_arg);
5335         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5336         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5337         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
5338         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5339         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5340         CVec_u8Z_free(ret_var);
5341         return ret_arr;
5342 }
5343
5344 uint64_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint64_t this_arg) {
5345         void* this_arg_ptr = untag_ptr(this_arg);
5346         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5347         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5348         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
5349         uint64_t ret_ref = 0;
5350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5351         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5352         return ret_ref;
5353 }
5354
5355 uint64_t  __attribute__((export_name("TS_KeysInterface_get_channel_signer"))) TS_KeysInterface_get_channel_signer(uint64_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
5356         void* this_arg_ptr = untag_ptr(this_arg);
5357         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5358         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5359         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5360         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
5361         return tag_ptr(ret_ret, true);
5362 }
5363
5364 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint64_t this_arg) {
5365         void* this_arg_ptr = untag_ptr(this_arg);
5366         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5367         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5368         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5369         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
5370         return ret_arr;
5371 }
5372
5373 uint64_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint64_t this_arg, int8_tArray reader) {
5374         void* this_arg_ptr = untag_ptr(this_arg);
5375         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5376         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5377         LDKu8slice reader_ref;
5378         reader_ref.datalen = reader->arr_len;
5379         reader_ref.data = reader->elems;
5380         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
5381         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
5382         FREE(reader);
5383         return tag_ptr(ret_conv, true);
5384 }
5385
5386 uint64_t  __attribute__((export_name("TS_KeysInterface_sign_invoice"))) TS_KeysInterface_sign_invoice(uint64_t this_arg, int8_tArray hrp_bytes, ptrArray invoice_data, uint32_t receipient) {
5387         void* this_arg_ptr = untag_ptr(this_arg);
5388         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5389         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5390         LDKu8slice hrp_bytes_ref;
5391         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
5392         hrp_bytes_ref.data = hrp_bytes->elems;
5393         LDKCVec_u5Z invoice_data_constr;
5394         invoice_data_constr.datalen = invoice_data->arr_len;
5395         if (invoice_data_constr.datalen > 0)
5396                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
5397         else
5398                 invoice_data_constr.data = NULL;
5399         int8_t* invoice_data_vals = (void*) invoice_data->elems;
5400         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
5401                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
5402                 
5403                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
5404         }
5405         FREE(invoice_data);
5406         LDKRecipient receipient_conv = LDKRecipient_from_js(receipient);
5407         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
5408         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
5409         FREE(hrp_bytes);
5410         return tag_ptr(ret_conv, true);
5411 }
5412
5413 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint64_t this_arg) {
5414         void* this_arg_ptr = untag_ptr(this_arg);
5415         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5416         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5417         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5418         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
5419         return ret_arr;
5420 }
5421
5422 typedef struct LDKFeeEstimator_JCalls {
5423         atomic_size_t refcnt;
5424         uint32_t instance_ptr;
5425 } LDKFeeEstimator_JCalls;
5426 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
5427         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5428         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5429                 FREE(j_calls);
5430         }
5431 }
5432 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
5433         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5434         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
5435         return js_invoke_function_uuuuuu(j_calls->instance_ptr, 29, confirmation_target_conv, 0, 0, 0, 0, 0);
5436 }
5437 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
5438         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
5439         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5440 }
5441 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
5442         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
5443         atomic_init(&calls->refcnt, 1);
5444         calls->instance_ptr = o;
5445
5446         LDKFeeEstimator ret = {
5447                 .this_arg = (void*) calls,
5448                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
5449                 .free = LDKFeeEstimator_JCalls_free,
5450         };
5451         return ret;
5452 }
5453 uint64_t  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
5454         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
5455         *res_ptr = LDKFeeEstimator_init(o);
5456         return tag_ptr(res_ptr, true);
5457 }
5458 int32_t  __attribute__((export_name("TS_FeeEstimator_get_est_sat_per_1000_weight"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint64_t this_arg, uint32_t confirmation_target) {
5459         void* this_arg_ptr = untag_ptr(this_arg);
5460         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5461         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
5462         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
5463         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
5464         return ret_conv;
5465 }
5466
5467 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5468         return ThirtyTwoBytes_clone(&owner->a);
5469 }
5470 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint64_t owner) {
5471         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
5472         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5473         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
5474         return ret_arr;
5475 }
5476
5477 static inline struct LDKChannelManager C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5478         LDKChannelManager ret = owner->b;
5479         ret.is_owned = false;
5480         return ret;
5481 }
5482 uint64_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint64_t owner) {
5483         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
5484         LDKChannelManager ret_var = C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
5485         uint64_t ret_ref = 0;
5486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5487         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5488         return ret_ref;
5489 }
5490
5491 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5492 CHECK(owner->result_ok);
5493         return &*owner->contents.result;
5494 }
5495 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint64_t owner) {
5496         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
5497         uint64_t ret_ret = tag_ptr(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv), false);
5498         return ret_ret;
5499 }
5500
5501 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5502         LDKDecodeError ret = *owner->contents.err;
5503         ret.is_owned = false;
5504         return ret;
5505 }
5506 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint64_t owner) {
5507         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
5508         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
5509         uint64_t ret_ref = 0;
5510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5511         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5512         return ret_ref;
5513 }
5514
5515 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5516         LDKChannelConfig ret = *owner->contents.result;
5517         ret.is_owned = false;
5518         return ret;
5519 }
5520 uint64_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint64_t owner) {
5521         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
5522         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
5523         uint64_t ret_ref = 0;
5524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5525         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5526         return ret_ref;
5527 }
5528
5529 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5530         LDKDecodeError ret = *owner->contents.err;
5531         ret.is_owned = false;
5532         return ret;
5533 }
5534 uint64_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint64_t owner) {
5535         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
5536         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
5537         uint64_t ret_ref = 0;
5538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5539         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5540         return ret_ref;
5541 }
5542
5543 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5544         LDKOutPoint ret = *owner->contents.result;
5545         ret.is_owned = false;
5546         return ret;
5547 }
5548 uint64_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint64_t owner) {
5549         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
5550         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
5551         uint64_t ret_ref = 0;
5552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5553         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5554         return ret_ref;
5555 }
5556
5557 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5558         LDKDecodeError ret = *owner->contents.err;
5559         ret.is_owned = false;
5560         return ret;
5561 }
5562 uint64_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint64_t owner) {
5563         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
5564         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
5565         uint64_t ret_ref = 0;
5566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5567         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5568         return ret_ref;
5569 }
5570
5571 typedef struct LDKType_JCalls {
5572         atomic_size_t refcnt;
5573         uint32_t instance_ptr;
5574 } LDKType_JCalls;
5575 static void LDKType_JCalls_free(void* this_arg) {
5576         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5577         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5578                 FREE(j_calls);
5579         }
5580 }
5581 uint16_t type_id_LDKType_jcall(const void* this_arg) {
5582         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5583         return js_invoke_function_uuuuuu(j_calls->instance_ptr, 30, 0, 0, 0, 0, 0, 0);
5584 }
5585 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
5586         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5587         jstring ret = (jstring)js_invoke_function_uuuuuu(j_calls->instance_ptr, 31, 0, 0, 0, 0, 0, 0);
5588         LDKStr ret_conv = str_ref_to_owned_c(ret);
5589         return ret_conv;
5590 }
5591 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
5592         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5593         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 32, 0, 0, 0, 0, 0, 0);
5594         LDKCVec_u8Z ret_ref;
5595         ret_ref.datalen = ret->arr_len;
5596         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5597         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5598         return ret_ref;
5599 }
5600 static void LDKType_JCalls_cloned(LDKType* new_obj) {
5601         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
5602         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5603 }
5604 static inline LDKType LDKType_init (JSValue o) {
5605         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5606         atomic_init(&calls->refcnt, 1);
5607         calls->instance_ptr = o;
5608
5609         LDKType ret = {
5610                 .this_arg = (void*) calls,
5611                 .type_id = type_id_LDKType_jcall,
5612                 .debug_str = debug_str_LDKType_jcall,
5613                 .write = write_LDKType_jcall,
5614                 .cloned = LDKType_JCalls_cloned,
5615                 .free = LDKType_JCalls_free,
5616         };
5617         return ret;
5618 }
5619 uint64_t  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
5620         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5621         *res_ptr = LDKType_init(o);
5622         return tag_ptr(res_ptr, true);
5623 }
5624 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint64_t this_arg) {
5625         void* this_arg_ptr = untag_ptr(this_arg);
5626         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5627         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5628         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5629         return ret_conv;
5630 }
5631
5632 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint64_t this_arg) {
5633         void* this_arg_ptr = untag_ptr(this_arg);
5634         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5635         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5636         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5637         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5638         Str_free(ret_str);
5639         return ret_conv;
5640 }
5641
5642 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint64_t this_arg) {
5643         void* this_arg_ptr = untag_ptr(this_arg);
5644         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5645         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5646         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5647         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5648         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5649         CVec_u8Z_free(ret_var);
5650         return ret_arr;
5651 }
5652
5653 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint64_t ptr) {
5654         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
5655         switch(obj->tag) {
5656                 case LDKCOption_TypeZ_Some: return 0;
5657                 case LDKCOption_TypeZ_None: return 1;
5658                 default: abort();
5659         }
5660 }
5661 uint64_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint64_t ptr) {
5662         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
5663         assert(obj->tag == LDKCOption_TypeZ_Some);
5664                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5665                         *some_ret = Type_clone(&obj->some);
5666         return tag_ptr(some_ret, true);
5667 }
5668 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5669 CHECK(owner->result_ok);
5670         return COption_TypeZ_clone(&*owner->contents.result);
5671 }
5672 uint64_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint64_t owner) {
5673         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
5674         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
5675         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
5676         uint64_t ret_ref = tag_ptr(ret_copy, true);
5677         return ret_ref;
5678 }
5679
5680 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5681         LDKDecodeError ret = *owner->contents.err;
5682         ret.is_owned = false;
5683         return ret;
5684 }
5685 uint64_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint64_t owner) {
5686         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
5687         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
5688         uint64_t ret_ref = 0;
5689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5690         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5691         return ret_ref;
5692 }
5693
5694 uint32_t __attribute__((export_name("TS_LDKPaymentError_ty_from_ptr"))) TS_LDKPaymentError_ty_from_ptr(uint64_t ptr) {
5695         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
5696         switch(obj->tag) {
5697                 case LDKPaymentError_Invoice: return 0;
5698                 case LDKPaymentError_Routing: return 1;
5699                 case LDKPaymentError_Sending: return 2;
5700                 default: abort();
5701         }
5702 }
5703 jstring __attribute__((export_name("TS_LDKPaymentError_Invoice_get_invoice"))) TS_LDKPaymentError_Invoice_get_invoice(uint64_t ptr) {
5704         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
5705         assert(obj->tag == LDKPaymentError_Invoice);
5706                         LDKStr invoice_str = obj->invoice;
5707                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
5708         return invoice_conv;
5709 }
5710 uint64_t __attribute__((export_name("TS_LDKPaymentError_Routing_get_routing"))) TS_LDKPaymentError_Routing_get_routing(uint64_t ptr) {
5711         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
5712         assert(obj->tag == LDKPaymentError_Routing);
5713                         LDKLightningError routing_var = obj->routing;
5714                         uint64_t routing_ref = 0;
5715                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
5716                         routing_ref = tag_ptr(routing_var.inner, false);
5717         return routing_ref;
5718 }
5719 uint64_t __attribute__((export_name("TS_LDKPaymentError_Sending_get_sending"))) TS_LDKPaymentError_Sending_get_sending(uint64_t ptr) {
5720         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
5721         assert(obj->tag == LDKPaymentError_Sending);
5722                         uint64_t sending_ref = tag_ptr(&obj->sending, false);
5723         return sending_ref;
5724 }
5725 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5726 CHECK(owner->result_ok);
5727         return ThirtyTwoBytes_clone(&*owner->contents.result);
5728 }
5729 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_ok"))) TS_CResult_PaymentIdPaymentErrorZ_get_ok(uint64_t owner) {
5730         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
5731         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5732         memcpy(ret_arr->elems, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data, 32);
5733         return ret_arr;
5734 }
5735
5736 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5737 CHECK(!owner->result_ok);
5738         return PaymentError_clone(&*owner->contents.err);
5739 }
5740 uint64_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_err"))) TS_CResult_PaymentIdPaymentErrorZ_get_err(uint64_t owner) {
5741         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
5742         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
5743         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
5744         uint64_t ret_ref = tag_ptr(ret_copy, true);
5745         return ret_ref;
5746 }
5747
5748 static inline struct LDKInFlightHtlcs CResult_InFlightHtlcsDecodeErrorZ_get_ok(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
5749         LDKInFlightHtlcs ret = *owner->contents.result;
5750         ret.is_owned = false;
5751         return ret;
5752 }
5753 uint64_t  __attribute__((export_name("TS_CResult_InFlightHtlcsDecodeErrorZ_get_ok"))) TS_CResult_InFlightHtlcsDecodeErrorZ_get_ok(uint64_t owner) {
5754         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
5755         LDKInFlightHtlcs ret_var = CResult_InFlightHtlcsDecodeErrorZ_get_ok(owner_conv);
5756         uint64_t ret_ref = 0;
5757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5758         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5759         return ret_ref;
5760 }
5761
5762 static inline struct LDKDecodeError CResult_InFlightHtlcsDecodeErrorZ_get_err(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
5763         LDKDecodeError ret = *owner->contents.err;
5764         ret.is_owned = false;
5765         return ret;
5766 }
5767 uint64_t  __attribute__((export_name("TS_CResult_InFlightHtlcsDecodeErrorZ_get_err"))) TS_CResult_InFlightHtlcsDecodeErrorZ_get_err(uint64_t owner) {
5768         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
5769         LDKDecodeError ret_var = CResult_InFlightHtlcsDecodeErrorZ_get_err(owner_conv);
5770         uint64_t ret_ref = 0;
5771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5772         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5773         return ret_ref;
5774 }
5775
5776 uint32_t __attribute__((export_name("TS_LDKParseError_ty_from_ptr"))) TS_LDKParseError_ty_from_ptr(uint64_t ptr) {
5777         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
5778         switch(obj->tag) {
5779                 case LDKParseError_Bech32Error: return 0;
5780                 case LDKParseError_ParseAmountError: return 1;
5781                 case LDKParseError_MalformedSignature: return 2;
5782                 case LDKParseError_BadPrefix: return 3;
5783                 case LDKParseError_UnknownCurrency: return 4;
5784                 case LDKParseError_UnknownSiPrefix: return 5;
5785                 case LDKParseError_MalformedHRP: return 6;
5786                 case LDKParseError_TooShortDataPart: return 7;
5787                 case LDKParseError_UnexpectedEndOfTaggedFields: return 8;
5788                 case LDKParseError_DescriptionDecodeError: return 9;
5789                 case LDKParseError_PaddingError: return 10;
5790                 case LDKParseError_IntegerOverflowError: return 11;
5791                 case LDKParseError_InvalidSegWitProgramLength: return 12;
5792                 case LDKParseError_InvalidPubKeyHashLength: return 13;
5793                 case LDKParseError_InvalidScriptHashLength: return 14;
5794                 case LDKParseError_InvalidRecoveryId: return 15;
5795                 case LDKParseError_InvalidSliceLength: return 16;
5796                 case LDKParseError_Skip: return 17;
5797                 default: abort();
5798         }
5799 }
5800 uint64_t __attribute__((export_name("TS_LDKParseError_Bech32Error_get_bech32_error"))) TS_LDKParseError_Bech32Error_get_bech32_error(uint64_t ptr) {
5801         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
5802         assert(obj->tag == LDKParseError_Bech32Error);
5803                         uint64_t bech32_error_ref = tag_ptr(&obj->bech32_error, false);
5804         return bech32_error_ref;
5805 }
5806 int32_t __attribute__((export_name("TS_LDKParseError_ParseAmountError_get_parse_amount_error"))) TS_LDKParseError_ParseAmountError_get_parse_amount_error(uint64_t ptr) {
5807         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
5808         assert(obj->tag == LDKParseError_ParseAmountError);
5809                         /*obj->parse_amount_error*/
5810         return 0;
5811 }
5812 uint32_t __attribute__((export_name("TS_LDKParseError_MalformedSignature_get_malformed_signature"))) TS_LDKParseError_MalformedSignature_get_malformed_signature(uint64_t ptr) {
5813         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
5814         assert(obj->tag == LDKParseError_MalformedSignature);
5815                         uint32_t malformed_signature_conv = LDKSecp256k1Error_to_js(obj->malformed_signature);
5816         return malformed_signature_conv;
5817 }
5818 int32_t __attribute__((export_name("TS_LDKParseError_DescriptionDecodeError_get_description_decode_error"))) TS_LDKParseError_DescriptionDecodeError_get_description_decode_error(uint64_t ptr) {
5819         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
5820         assert(obj->tag == LDKParseError_DescriptionDecodeError);
5821                         /*obj->description_decode_error*/
5822         return 0;
5823 }
5824 jstring __attribute__((export_name("TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length"))) TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length(uint64_t ptr) {
5825         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
5826         assert(obj->tag == LDKParseError_InvalidSliceLength);
5827                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
5828                         jstring invalid_slice_length_conv = str_ref_to_ts(invalid_slice_length_str.chars, invalid_slice_length_str.len);
5829         return invalid_slice_length_conv;
5830 }
5831 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5832 CHECK(owner->result_ok);
5833         return SiPrefix_clone(&*owner->contents.result);
5834 }
5835 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_ok"))) TS_CResult_SiPrefixParseErrorZ_get_ok(uint64_t owner) {
5836         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
5837         uint32_t ret_conv = LDKSiPrefix_to_js(CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
5838         return ret_conv;
5839 }
5840
5841 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5842 CHECK(!owner->result_ok);
5843         return ParseError_clone(&*owner->contents.err);
5844 }
5845 uint64_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_err"))) TS_CResult_SiPrefixParseErrorZ_get_err(uint64_t owner) {
5846         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
5847         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
5848         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
5849         uint64_t ret_ref = tag_ptr(ret_copy, true);
5850         return ret_ref;
5851 }
5852
5853 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ty_from_ptr"))) TS_LDKParseOrSemanticError_ty_from_ptr(uint64_t ptr) {
5854         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
5855         switch(obj->tag) {
5856                 case LDKParseOrSemanticError_ParseError: return 0;
5857                 case LDKParseOrSemanticError_SemanticError: return 1;
5858                 default: abort();
5859         }
5860 }
5861 uint64_t __attribute__((export_name("TS_LDKParseOrSemanticError_ParseError_get_parse_error"))) TS_LDKParseOrSemanticError_ParseError_get_parse_error(uint64_t ptr) {
5862         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
5863         assert(obj->tag == LDKParseOrSemanticError_ParseError);
5864                         uint64_t parse_error_ref = tag_ptr(&obj->parse_error, false);
5865         return parse_error_ref;
5866 }
5867 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_SemanticError_get_semantic_error"))) TS_LDKParseOrSemanticError_SemanticError_get_semantic_error(uint64_t ptr) {
5868         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
5869         assert(obj->tag == LDKParseOrSemanticError_SemanticError);
5870                         uint32_t semantic_error_conv = LDKSemanticError_to_js(obj->semantic_error);
5871         return semantic_error_conv;
5872 }
5873 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5874         LDKInvoice ret = *owner->contents.result;
5875         ret.is_owned = false;
5876         return ret;
5877 }
5878 uint64_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok(uint64_t owner) {
5879         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
5880         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
5881         uint64_t ret_ref = 0;
5882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5883         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5884         return ret_ref;
5885 }
5886
5887 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5888 CHECK(!owner->result_ok);
5889         return ParseOrSemanticError_clone(&*owner->contents.err);
5890 }
5891 uint64_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_err(uint64_t owner) {
5892         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
5893         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
5894         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
5895         uint64_t ret_ref = tag_ptr(ret_copy, true);
5896         return ret_ref;
5897 }
5898
5899 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
5900         LDKSignedRawInvoice ret = *owner->contents.result;
5901         ret.is_owned = false;
5902         return ret;
5903 }
5904 uint64_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_ok(uint64_t owner) {
5905         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
5906         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
5907         uint64_t ret_ref = 0;
5908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5910         return ret_ref;
5911 }
5912
5913 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
5914 CHECK(!owner->result_ok);
5915         return ParseError_clone(&*owner->contents.err);
5916 }
5917 uint64_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_err(uint64_t owner) {
5918         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
5919         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
5920         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
5921         uint64_t ret_ref = tag_ptr(ret_copy, true);
5922         return ret_ref;
5923 }
5924
5925 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5926         LDKRawInvoice ret = owner->a;
5927         ret.is_owned = false;
5928         return ret;
5929 }
5930 uint64_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint64_t owner) {
5931         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
5932         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
5933         uint64_t ret_ref = 0;
5934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5935         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5936         return ret_ref;
5937 }
5938
5939 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5940         return ThirtyTwoBytes_clone(&owner->b);
5941 }
5942 int8_tArray  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint64_t owner) {
5943         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
5944         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5945         memcpy(ret_arr->elems, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data, 32);
5946         return ret_arr;
5947 }
5948
5949 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5950         LDKInvoiceSignature ret = owner->c;
5951         ret.is_owned = false;
5952         return ret;
5953 }
5954 uint64_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint64_t owner) {
5955         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
5956         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
5957         uint64_t ret_ref = 0;
5958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5959         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5960         return ret_ref;
5961 }
5962
5963 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5964         LDKPayeePubKey ret = *owner->contents.result;
5965         ret.is_owned = false;
5966         return ret;
5967 }
5968 uint64_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_ok"))) TS_CResult_PayeePubKeyErrorZ_get_ok(uint64_t owner) {
5969         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
5970         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
5971         uint64_t ret_ref = 0;
5972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5973         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5974         return ret_ref;
5975 }
5976
5977 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5978 CHECK(!owner->result_ok);
5979         return *owner->contents.err;
5980 }
5981 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_err"))) TS_CResult_PayeePubKeyErrorZ_get_err(uint64_t owner) {
5982         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
5983         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PayeePubKeyErrorZ_get_err(owner_conv));
5984         return ret_conv;
5985 }
5986
5987 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
5988         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
5989         for (size_t i = 0; i < ret.datalen; i++) {
5990                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
5991         }
5992         return ret;
5993 }
5994 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5995         LDKPositiveTimestamp ret = *owner->contents.result;
5996         ret.is_owned = false;
5997         return ret;
5998 }
5999 uint64_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_get_ok(uint64_t owner) {
6000         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
6001         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
6002         uint64_t ret_ref = 0;
6003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6004         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6005         return ret_ref;
6006 }
6007
6008 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6009 CHECK(!owner->result_ok);
6010         return CreationError_clone(&*owner->contents.err);
6011 }
6012 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_err"))) TS_CResult_PositiveTimestampCreationErrorZ_get_err(uint64_t owner) {
6013         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
6014         uint32_t ret_conv = LDKCreationError_to_js(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
6015         return ret_conv;
6016 }
6017
6018 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6019 CHECK(owner->result_ok);
6020         return *owner->contents.result;
6021 }
6022 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_ok"))) TS_CResult_NoneSemanticErrorZ_get_ok(uint64_t owner) {
6023         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
6024         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
6025 }
6026
6027 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6028 CHECK(!owner->result_ok);
6029         return SemanticError_clone(&*owner->contents.err);
6030 }
6031 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_err"))) TS_CResult_NoneSemanticErrorZ_get_err(uint64_t owner) {
6032         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
6033         uint32_t ret_conv = LDKSemanticError_to_js(CResult_NoneSemanticErrorZ_get_err(owner_conv));
6034         return ret_conv;
6035 }
6036
6037 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6038         LDKInvoice ret = *owner->contents.result;
6039         ret.is_owned = false;
6040         return ret;
6041 }
6042 uint64_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_ok"))) TS_CResult_InvoiceSemanticErrorZ_get_ok(uint64_t owner) {
6043         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
6044         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
6045         uint64_t ret_ref = 0;
6046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6047         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6048         return ret_ref;
6049 }
6050
6051 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6052 CHECK(!owner->result_ok);
6053         return SemanticError_clone(&*owner->contents.err);
6054 }
6055 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_err"))) TS_CResult_InvoiceSemanticErrorZ_get_err(uint64_t owner) {
6056         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
6057         uint32_t ret_conv = LDKSemanticError_to_js(CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
6058         return ret_conv;
6059 }
6060
6061 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6062         LDKDescription ret = *owner->contents.result;
6063         ret.is_owned = false;
6064         return ret;
6065 }
6066 uint64_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_ok"))) TS_CResult_DescriptionCreationErrorZ_get_ok(uint64_t owner) {
6067         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
6068         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
6069         uint64_t ret_ref = 0;
6070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6071         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6072         return ret_ref;
6073 }
6074
6075 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6076 CHECK(!owner->result_ok);
6077         return CreationError_clone(&*owner->contents.err);
6078 }
6079 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_err"))) TS_CResult_DescriptionCreationErrorZ_get_err(uint64_t owner) {
6080         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
6081         uint32_t ret_conv = LDKCreationError_to_js(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
6082         return ret_conv;
6083 }
6084
6085 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6086         LDKPrivateRoute ret = *owner->contents.result;
6087         ret.is_owned = false;
6088         return ret;
6089 }
6090 uint64_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_ok"))) TS_CResult_PrivateRouteCreationErrorZ_get_ok(uint64_t owner) {
6091         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
6092         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
6093         uint64_t ret_ref = 0;
6094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6095         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6096         return ret_ref;
6097 }
6098
6099 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6100 CHECK(!owner->result_ok);
6101         return CreationError_clone(&*owner->contents.err);
6102 }
6103 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_err"))) TS_CResult_PrivateRouteCreationErrorZ_get_err(uint64_t owner) {
6104         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
6105         uint32_t ret_conv = LDKCreationError_to_js(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
6106         return ret_conv;
6107 }
6108
6109 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6110 CHECK(owner->result_ok);
6111         return *owner->contents.result;
6112 }
6113 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint64_t owner) {
6114         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
6115         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
6116         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6117         return ret_conv;
6118 }
6119
6120 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6121 CHECK(!owner->result_ok);
6122         return *owner->contents.err;
6123 }
6124 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint64_t owner) {
6125         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
6126         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
6127         return ret_conv;
6128 }
6129
6130 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6131         LDKChannelMonitorUpdate ret = *owner->contents.result;
6132         ret.is_owned = false;
6133         return ret;
6134 }
6135 uint64_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint64_t owner) {
6136         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
6137         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
6138         uint64_t ret_ref = 0;
6139         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6140         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6141         return ret_ref;
6142 }
6143
6144 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6145         LDKDecodeError ret = *owner->contents.err;
6146         ret.is_owned = false;
6147         return ret;
6148 }
6149 uint64_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint64_t owner) {
6150         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
6151         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
6152         uint64_t ret_ref = 0;
6153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6154         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6155         return ret_ref;
6156 }
6157
6158 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint64_t ptr) {
6159         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
6160         switch(obj->tag) {
6161                 case LDKCOption_MonitorEventZ_Some: return 0;
6162                 case LDKCOption_MonitorEventZ_None: return 1;
6163                 default: abort();
6164         }
6165 }
6166 uint64_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint64_t ptr) {
6167         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
6168         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
6169                         uint64_t some_ref = tag_ptr(&obj->some, false);
6170         return some_ref;
6171 }
6172 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6173 CHECK(owner->result_ok);
6174         return COption_MonitorEventZ_clone(&*owner->contents.result);
6175 }
6176 uint64_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint64_t owner) {
6177         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
6178         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
6179         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
6180         uint64_t ret_ref = tag_ptr(ret_copy, true);
6181         return ret_ref;
6182 }
6183
6184 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6185         LDKDecodeError ret = *owner->contents.err;
6186         ret.is_owned = false;
6187         return ret;
6188 }
6189 uint64_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint64_t owner) {
6190         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
6191         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
6192         uint64_t ret_ref = 0;
6193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6194         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6195         return ret_ref;
6196 }
6197
6198 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6199         LDKHTLCUpdate ret = *owner->contents.result;
6200         ret.is_owned = false;
6201         return ret;
6202 }
6203 uint64_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint64_t owner) {
6204         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
6205         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
6206         uint64_t ret_ref = 0;
6207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6208         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6209         return ret_ref;
6210 }
6211
6212 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6213         LDKDecodeError ret = *owner->contents.err;
6214         ret.is_owned = false;
6215         return ret;
6216 }
6217 uint64_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint64_t owner) {
6218         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
6219         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
6220         uint64_t ret_ref = 0;
6221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6222         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6223         return ret_ref;
6224 }
6225
6226 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6227         LDKOutPoint ret = owner->a;
6228         ret.is_owned = false;
6229         return ret;
6230 }
6231 uint64_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint64_t owner) {
6232         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
6233         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
6234         uint64_t ret_ref = 0;
6235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6236         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6237         return ret_ref;
6238 }
6239
6240 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6241         return CVec_u8Z_clone(&owner->b);
6242 }
6243 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint64_t owner) {
6244         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
6245         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
6246         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6247         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6248         CVec_u8Z_free(ret_var);
6249         return ret_arr;
6250 }
6251
6252 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6253         return owner->a;
6254 }
6255 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint64_t owner) {
6256         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
6257         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
6258         return ret_conv;
6259 }
6260
6261 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6262         return CVec_u8Z_clone(&owner->b);
6263 }
6264 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint64_t owner) {
6265         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
6266         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
6267         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6268         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6269         CVec_u8Z_free(ret_var);
6270         return ret_arr;
6271 }
6272
6273 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
6274         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
6275         for (size_t i = 0; i < ret.datalen; i++) {
6276                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
6277         }
6278         return ret;
6279 }
6280 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6281         return ThirtyTwoBytes_clone(&owner->a);
6282 }
6283 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint64_t owner) {
6284         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
6285         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6286         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
6287         return ret_arr;
6288 }
6289
6290 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6291         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
6292 }
6293 uint64_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint64_t owner) {
6294         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
6295         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
6296         uint64_tArray ret_arr = NULL;
6297         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
6298         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
6299         for (size_t v = 0; v < ret_var.datalen; v++) {
6300                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6301                 *ret_conv_21_conv = ret_var.data[v];
6302                 ret_arr_ptr[v] = tag_ptr(ret_conv_21_conv, true);
6303         }
6304         
6305         FREE(ret_var.data);
6306         return ret_arr;
6307 }
6308
6309 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
6310         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 };
6311         for (size_t i = 0; i < ret.datalen; i++) {
6312                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
6313         }
6314         return ret;
6315 }
6316 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
6317         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
6318         for (size_t i = 0; i < ret.datalen; i++) {
6319                 ret.data[i] = Event_clone(&orig->data[i]);
6320         }
6321         return ret;
6322 }
6323 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6324         return owner->a;
6325 }
6326 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint64_t owner) {
6327         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
6328         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
6329         return ret_conv;
6330 }
6331
6332 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6333         return TxOut_clone(&owner->b);
6334 }
6335 uint64_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint64_t owner) {
6336         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
6337         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6338         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
6339         return tag_ptr(ret_ref, true);
6340 }
6341
6342 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
6343         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
6344         for (size_t i = 0; i < ret.datalen; i++) {
6345                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
6346         }
6347         return ret;
6348 }
6349 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6350         return ThirtyTwoBytes_clone(&owner->a);
6351 }
6352 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint64_t owner) {
6353         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
6354         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6355         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
6356         return ret_arr;
6357 }
6358
6359 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6360         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
6361 }
6362 uint64_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint64_t owner) {
6363         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
6364         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
6365         uint64_tArray ret_arr = NULL;
6366         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
6367         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
6368         for (size_t u = 0; u < ret_var.datalen; u++) {
6369                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6370                 *ret_conv_20_conv = ret_var.data[u];
6371                 ret_arr_ptr[u] = tag_ptr(ret_conv_20_conv, true);
6372         }
6373         
6374         FREE(ret_var.data);
6375         return ret_arr;
6376 }
6377
6378 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
6379         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 };
6380         for (size_t i = 0; i < ret.datalen; i++) {
6381                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
6382         }
6383         return ret;
6384 }
6385 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint64_t ptr) {
6386         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
6387         switch(obj->tag) {
6388                 case LDKBalance_ClaimableOnChannelClose: return 0;
6389                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
6390                 case LDKBalance_ContentiousClaimable: return 2;
6391                 case LDKBalance_MaybeTimeoutClaimableHTLC: return 3;
6392                 case LDKBalance_MaybePreimageClaimableHTLC: return 4;
6393                 case LDKBalance_CounterpartyRevokedOutputClaimable: return 5;
6394                 default: abort();
6395         }
6396 }
6397 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint64_t ptr) {
6398         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
6399         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
6400                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
6401         return claimable_amount_satoshis_conv;
6402 }
6403 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint64_t ptr) {
6404         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
6405         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
6406                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
6407         return claimable_amount_satoshis_conv;
6408 }
6409 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint64_t ptr) {
6410         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
6411         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
6412                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
6413         return confirmation_height_conv;
6414 }
6415 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint64_t ptr) {
6416         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
6417         assert(obj->tag == LDKBalance_ContentiousClaimable);
6418                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
6419         return claimable_amount_satoshis_conv;
6420 }
6421 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint64_t ptr) {
6422         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
6423         assert(obj->tag == LDKBalance_ContentiousClaimable);
6424                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
6425         return timeout_height_conv;
6426 }
6427 int64_t __attribute__((export_name("TS_LDKBalance_MaybeTimeoutClaimableHTLC_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeTimeoutClaimableHTLC_get_claimable_amount_satoshis(uint64_t ptr) {
6428         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
6429         assert(obj->tag == LDKBalance_MaybeTimeoutClaimableHTLC);
6430                         int64_t claimable_amount_satoshis_conv = obj->maybe_timeout_claimable_htlc.claimable_amount_satoshis;
6431         return claimable_amount_satoshis_conv;
6432 }
6433 int32_t __attribute__((export_name("TS_LDKBalance_MaybeTimeoutClaimableHTLC_get_claimable_height"))) TS_LDKBalance_MaybeTimeoutClaimableHTLC_get_claimable_height(uint64_t ptr) {
6434         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
6435         assert(obj->tag == LDKBalance_MaybeTimeoutClaimableHTLC);
6436                         int32_t claimable_height_conv = obj->maybe_timeout_claimable_htlc.claimable_height;
6437         return claimable_height_conv;
6438 }
6439 int64_t __attribute__((export_name("TS_LDKBalance_MaybePreimageClaimableHTLC_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybePreimageClaimableHTLC_get_claimable_amount_satoshis(uint64_t ptr) {
6440         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
6441         assert(obj->tag == LDKBalance_MaybePreimageClaimableHTLC);
6442                         int64_t claimable_amount_satoshis_conv = obj->maybe_preimage_claimable_htlc.claimable_amount_satoshis;
6443         return claimable_amount_satoshis_conv;
6444 }
6445 int32_t __attribute__((export_name("TS_LDKBalance_MaybePreimageClaimableHTLC_get_expiry_height"))) TS_LDKBalance_MaybePreimageClaimableHTLC_get_expiry_height(uint64_t ptr) {
6446         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
6447         assert(obj->tag == LDKBalance_MaybePreimageClaimableHTLC);
6448                         int32_t expiry_height_conv = obj->maybe_preimage_claimable_htlc.expiry_height;
6449         return expiry_height_conv;
6450 }
6451 int64_t __attribute__((export_name("TS_LDKBalance_CounterpartyRevokedOutputClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_CounterpartyRevokedOutputClaimable_get_claimable_amount_satoshis(uint64_t ptr) {
6452         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
6453         assert(obj->tag == LDKBalance_CounterpartyRevokedOutputClaimable);
6454                         int64_t claimable_amount_satoshis_conv = obj->counterparty_revoked_output_claimable.claimable_amount_satoshis;
6455         return claimable_amount_satoshis_conv;
6456 }
6457 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
6458         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
6459         for (size_t i = 0; i < ret.datalen; i++) {
6460                 ret.data[i] = Balance_clone(&orig->data[i]);
6461         }
6462         return ret;
6463 }
6464 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6465         return ThirtyTwoBytes_clone(&owner->a);
6466 }
6467 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint64_t owner) {
6468         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6469         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6470         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
6471         return ret_arr;
6472 }
6473
6474 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6475         LDKChannelMonitor ret = owner->b;
6476         ret.is_owned = false;
6477         return ret;
6478 }
6479 uint64_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint64_t owner) {
6480         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6481         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6482         uint64_t ret_ref = 0;
6483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6484         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6485         return ret_ref;
6486 }
6487
6488 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6489 CHECK(owner->result_ok);
6490         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
6491 }
6492 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint64_t owner) {
6493         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
6494         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6495         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
6496         return tag_ptr(ret_conv, true);
6497 }
6498
6499 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6500         LDKDecodeError ret = *owner->contents.err;
6501         ret.is_owned = false;
6502         return ret;
6503 }
6504 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint64_t owner) {
6505         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
6506         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
6507         uint64_t ret_ref = 0;
6508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6509         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6510         return ret_ref;
6511 }
6512
6513 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6514         return owner->a;
6515 }
6516 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint64_t owner) {
6517         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
6518         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
6519         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
6520         return ret_arr;
6521 }
6522
6523 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6524         return Type_clone(&owner->b);
6525 }
6526 uint64_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint64_t owner) {
6527         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
6528         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
6529         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
6530         return tag_ptr(ret_ret, true);
6531 }
6532
6533 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
6534         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
6535         for (size_t i = 0; i < ret.datalen; i++) {
6536                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
6537         }
6538         return ret;
6539 }
6540 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_ty_from_ptr"))) TS_LDKCOption_NetAddressZ_ty_from_ptr(uint64_t ptr) {
6541         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)untag_ptr(ptr);
6542         switch(obj->tag) {
6543                 case LDKCOption_NetAddressZ_Some: return 0;
6544                 case LDKCOption_NetAddressZ_None: return 1;
6545                 default: abort();
6546         }
6547 }
6548 uint64_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_Some_get_some"))) TS_LDKCOption_NetAddressZ_Some_get_some(uint64_t ptr) {
6549         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)untag_ptr(ptr);
6550         assert(obj->tag == LDKCOption_NetAddressZ_Some);
6551                         uint64_t some_ref = tag_ptr(&obj->some, false);
6552         return some_ref;
6553 }
6554 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6555 CHECK(owner->result_ok);
6556         return CVec_u8Z_clone(&*owner->contents.result);
6557 }
6558 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint64_t owner) {
6559         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
6560         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
6561         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6562         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6563         CVec_u8Z_free(ret_var);
6564         return ret_arr;
6565 }
6566
6567 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6568         LDKPeerHandleError ret = *owner->contents.err;
6569         ret.is_owned = false;
6570         return ret;
6571 }
6572 uint64_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint64_t owner) {
6573         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
6574         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
6575         uint64_t ret_ref = 0;
6576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6577         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6578         return ret_ref;
6579 }
6580
6581 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6582 CHECK(owner->result_ok);
6583         return *owner->contents.result;
6584 }
6585 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint64_t owner) {
6586         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
6587         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
6588 }
6589
6590 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6591         LDKPeerHandleError ret = *owner->contents.err;
6592         ret.is_owned = false;
6593         return ret;
6594 }
6595 uint64_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint64_t owner) {
6596         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
6597         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
6598         uint64_t ret_ref = 0;
6599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6600         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6601         return ret_ref;
6602 }
6603
6604 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6605 CHECK(owner->result_ok);
6606         return *owner->contents.result;
6607 }
6608 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint64_t owner) {
6609         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
6610         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
6611         return ret_conv;
6612 }
6613
6614 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6615         LDKPeerHandleError ret = *owner->contents.err;
6616         ret.is_owned = false;
6617         return ret;
6618 }
6619 uint64_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint64_t owner) {
6620         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
6621         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
6622         uint64_t ret_ref = 0;
6623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6624         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6625         return ret_ref;
6626 }
6627
6628 uint32_t __attribute__((export_name("TS_LDKSendError_ty_from_ptr"))) TS_LDKSendError_ty_from_ptr(uint64_t ptr) {
6629         LDKSendError *obj = (LDKSendError*)untag_ptr(ptr);
6630         switch(obj->tag) {
6631                 case LDKSendError_Secp256k1: return 0;
6632                 case LDKSendError_TooBigPacket: return 1;
6633                 case LDKSendError_TooFewBlindedHops: return 2;
6634                 case LDKSendError_InvalidFirstHop: return 3;
6635                 case LDKSendError_BufferFull: return 4;
6636                 default: abort();
6637         }
6638 }
6639 uint32_t __attribute__((export_name("TS_LDKSendError_Secp256k1_get_secp256k1"))) TS_LDKSendError_Secp256k1_get_secp256k1(uint64_t ptr) {
6640         LDKSendError *obj = (LDKSendError*)untag_ptr(ptr);
6641         assert(obj->tag == LDKSendError_Secp256k1);
6642                         uint32_t secp256k1_conv = LDKSecp256k1Error_to_js(obj->secp256k1);
6643         return secp256k1_conv;
6644 }
6645 static inline void CResult_NoneSendErrorZ_get_ok(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
6646 CHECK(owner->result_ok);
6647         return *owner->contents.result;
6648 }
6649 void  __attribute__((export_name("TS_CResult_NoneSendErrorZ_get_ok"))) TS_CResult_NoneSendErrorZ_get_ok(uint64_t owner) {
6650         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
6651         CResult_NoneSendErrorZ_get_ok(owner_conv);
6652 }
6653
6654 static inline struct LDKSendError CResult_NoneSendErrorZ_get_err(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
6655 CHECK(!owner->result_ok);
6656         return SendError_clone(&*owner->contents.err);
6657 }
6658 uint64_t  __attribute__((export_name("TS_CResult_NoneSendErrorZ_get_err"))) TS_CResult_NoneSendErrorZ_get_err(uint64_t owner) {
6659         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
6660         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
6661         *ret_copy = CResult_NoneSendErrorZ_get_err(owner_conv);
6662         uint64_t ret_ref = tag_ptr(ret_copy, true);
6663         return ret_ref;
6664 }
6665
6666 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
6667 CHECK(owner->result_ok);
6668         return *owner->contents.result;
6669 }
6670 void  __attribute__((export_name("TS_CResult_NoneErrorZ_get_ok"))) TS_CResult_NoneErrorZ_get_ok(uint64_t owner) {
6671         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
6672         CResult_NoneErrorZ_get_ok(owner_conv);
6673 }
6674
6675 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
6676 CHECK(!owner->result_ok);
6677         return *owner->contents.err;
6678 }
6679 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_get_err"))) TS_CResult_NoneErrorZ_get_err(uint64_t owner) {
6680         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
6681         uint32_t ret_conv = LDKIOError_to_js(CResult_NoneErrorZ_get_err(owner_conv));
6682         return ret_conv;
6683 }
6684
6685 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6686 CHECK(owner->result_ok);
6687         return NetAddress_clone(&*owner->contents.result);
6688 }
6689 uint64_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint64_t owner) {
6690         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
6691         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
6692         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
6693         uint64_t ret_ref = tag_ptr(ret_copy, true);
6694         return ret_ref;
6695 }
6696
6697 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6698         LDKDecodeError ret = *owner->contents.err;
6699         ret.is_owned = false;
6700         return ret;
6701 }
6702 uint64_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint64_t owner) {
6703         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
6704         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
6705         uint64_t ret_ref = 0;
6706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6707         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6708         return ret_ref;
6709 }
6710
6711 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6712         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6713         for (size_t i = 0; i < ret.datalen; i++) {
6714                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6715         }
6716         return ret;
6717 }
6718 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6719         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6720         for (size_t i = 0; i < ret.datalen; i++) {
6721                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6722         }
6723         return ret;
6724 }
6725 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6726         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6727         for (size_t i = 0; i < ret.datalen; i++) {
6728                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6729         }
6730         return ret;
6731 }
6732 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6733         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6734         for (size_t i = 0; i < ret.datalen; i++) {
6735                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6736         }
6737         return ret;
6738 }
6739 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6740         LDKAcceptChannel ret = *owner->contents.result;
6741         ret.is_owned = false;
6742         return ret;
6743 }
6744 uint64_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint64_t owner) {
6745         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
6746         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
6747         uint64_t ret_ref = 0;
6748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6749         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6750         return ret_ref;
6751 }
6752
6753 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6754         LDKDecodeError ret = *owner->contents.err;
6755         ret.is_owned = false;
6756         return ret;
6757 }
6758 uint64_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint64_t owner) {
6759         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
6760         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
6761         uint64_t ret_ref = 0;
6762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6763         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6764         return ret_ref;
6765 }
6766
6767 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6768         LDKAnnouncementSignatures ret = *owner->contents.result;
6769         ret.is_owned = false;
6770         return ret;
6771 }
6772 uint64_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint64_t owner) {
6773         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
6774         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
6775         uint64_t ret_ref = 0;
6776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6777         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6778         return ret_ref;
6779 }
6780
6781 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6782         LDKDecodeError ret = *owner->contents.err;
6783         ret.is_owned = false;
6784         return ret;
6785 }
6786 uint64_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint64_t owner) {
6787         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
6788         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
6789         uint64_t ret_ref = 0;
6790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6791         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6792         return ret_ref;
6793 }
6794
6795 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6796         LDKChannelReestablish ret = *owner->contents.result;
6797         ret.is_owned = false;
6798         return ret;
6799 }
6800 uint64_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint64_t owner) {
6801         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
6802         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
6803         uint64_t ret_ref = 0;
6804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6805         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6806         return ret_ref;
6807 }
6808
6809 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6810         LDKDecodeError ret = *owner->contents.err;
6811         ret.is_owned = false;
6812         return ret;
6813 }
6814 uint64_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint64_t owner) {
6815         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
6816         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
6817         uint64_t ret_ref = 0;
6818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6819         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6820         return ret_ref;
6821 }
6822
6823 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6824         LDKClosingSigned ret = *owner->contents.result;
6825         ret.is_owned = false;
6826         return ret;
6827 }
6828 uint64_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint64_t owner) {
6829         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
6830         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
6831         uint64_t ret_ref = 0;
6832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6833         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6834         return ret_ref;
6835 }
6836
6837 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6838         LDKDecodeError ret = *owner->contents.err;
6839         ret.is_owned = false;
6840         return ret;
6841 }
6842 uint64_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint64_t owner) {
6843         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
6844         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
6845         uint64_t ret_ref = 0;
6846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6847         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6848         return ret_ref;
6849 }
6850
6851 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6852         LDKClosingSignedFeeRange ret = *owner->contents.result;
6853         ret.is_owned = false;
6854         return ret;
6855 }
6856 uint64_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint64_t owner) {
6857         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
6858         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
6859         uint64_t ret_ref = 0;
6860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6861         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6862         return ret_ref;
6863 }
6864
6865 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6866         LDKDecodeError ret = *owner->contents.err;
6867         ret.is_owned = false;
6868         return ret;
6869 }
6870 uint64_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint64_t owner) {
6871         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
6872         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
6873         uint64_t ret_ref = 0;
6874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6875         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6876         return ret_ref;
6877 }
6878
6879 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6880         LDKCommitmentSigned ret = *owner->contents.result;
6881         ret.is_owned = false;
6882         return ret;
6883 }
6884 uint64_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint64_t owner) {
6885         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
6886         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
6887         uint64_t ret_ref = 0;
6888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6889         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6890         return ret_ref;
6891 }
6892
6893 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6894         LDKDecodeError ret = *owner->contents.err;
6895         ret.is_owned = false;
6896         return ret;
6897 }
6898 uint64_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint64_t owner) {
6899         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
6900         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
6901         uint64_t ret_ref = 0;
6902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6903         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6904         return ret_ref;
6905 }
6906
6907 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6908         LDKFundingCreated ret = *owner->contents.result;
6909         ret.is_owned = false;
6910         return ret;
6911 }
6912 uint64_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint64_t owner) {
6913         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
6914         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
6915         uint64_t ret_ref = 0;
6916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6917         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6918         return ret_ref;
6919 }
6920
6921 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6922         LDKDecodeError ret = *owner->contents.err;
6923         ret.is_owned = false;
6924         return ret;
6925 }
6926 uint64_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint64_t owner) {
6927         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
6928         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
6929         uint64_t ret_ref = 0;
6930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6931         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6932         return ret_ref;
6933 }
6934
6935 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6936         LDKFundingSigned ret = *owner->contents.result;
6937         ret.is_owned = false;
6938         return ret;
6939 }
6940 uint64_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint64_t owner) {
6941         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
6942         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
6943         uint64_t ret_ref = 0;
6944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6945         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6946         return ret_ref;
6947 }
6948
6949 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6950         LDKDecodeError ret = *owner->contents.err;
6951         ret.is_owned = false;
6952         return ret;
6953 }
6954 uint64_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint64_t owner) {
6955         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
6956         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
6957         uint64_t ret_ref = 0;
6958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6959         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6960         return ret_ref;
6961 }
6962
6963 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
6964         LDKChannelReady ret = *owner->contents.result;
6965         ret.is_owned = false;
6966         return ret;
6967 }
6968 uint64_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_get_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_get_ok(uint64_t owner) {
6969         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
6970         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
6971         uint64_t ret_ref = 0;
6972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6973         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6974         return ret_ref;
6975 }
6976
6977 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
6978         LDKDecodeError ret = *owner->contents.err;
6979         ret.is_owned = false;
6980         return ret;
6981 }
6982 uint64_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_get_err"))) TS_CResult_ChannelReadyDecodeErrorZ_get_err(uint64_t owner) {
6983         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
6984         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
6985         uint64_t ret_ref = 0;
6986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6987         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6988         return ret_ref;
6989 }
6990
6991 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
6992         LDKInit ret = *owner->contents.result;
6993         ret.is_owned = false;
6994         return ret;
6995 }
6996 uint64_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint64_t owner) {
6997         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
6998         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
6999         uint64_t ret_ref = 0;
7000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7001         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7002         return ret_ref;
7003 }
7004
7005 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7006         LDKDecodeError ret = *owner->contents.err;
7007         ret.is_owned = false;
7008         return ret;
7009 }
7010 uint64_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint64_t owner) {
7011         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
7012         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
7013         uint64_t ret_ref = 0;
7014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7015         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7016         return ret_ref;
7017 }
7018
7019 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7020         LDKOpenChannel ret = *owner->contents.result;
7021         ret.is_owned = false;
7022         return ret;
7023 }
7024 uint64_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint64_t owner) {
7025         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
7026         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
7027         uint64_t ret_ref = 0;
7028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7029         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7030         return ret_ref;
7031 }
7032
7033 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7034         LDKDecodeError ret = *owner->contents.err;
7035         ret.is_owned = false;
7036         return ret;
7037 }
7038 uint64_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint64_t owner) {
7039         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
7040         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
7041         uint64_t ret_ref = 0;
7042         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7043         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7044         return ret_ref;
7045 }
7046
7047 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7048         LDKRevokeAndACK ret = *owner->contents.result;
7049         ret.is_owned = false;
7050         return ret;
7051 }
7052 uint64_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint64_t owner) {
7053         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
7054         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
7055         uint64_t ret_ref = 0;
7056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7057         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7058         return ret_ref;
7059 }
7060
7061 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7062         LDKDecodeError ret = *owner->contents.err;
7063         ret.is_owned = false;
7064         return ret;
7065 }
7066 uint64_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint64_t owner) {
7067         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
7068         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
7069         uint64_t ret_ref = 0;
7070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7071         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7072         return ret_ref;
7073 }
7074
7075 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7076         LDKShutdown ret = *owner->contents.result;
7077         ret.is_owned = false;
7078         return ret;
7079 }
7080 uint64_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint64_t owner) {
7081         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
7082         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
7083         uint64_t ret_ref = 0;
7084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7085         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7086         return ret_ref;
7087 }
7088
7089 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7090         LDKDecodeError ret = *owner->contents.err;
7091         ret.is_owned = false;
7092         return ret;
7093 }
7094 uint64_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint64_t owner) {
7095         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
7096         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
7097         uint64_t ret_ref = 0;
7098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7099         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7100         return ret_ref;
7101 }
7102
7103 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7104         LDKUpdateFailHTLC ret = *owner->contents.result;
7105         ret.is_owned = false;
7106         return ret;
7107 }
7108 uint64_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint64_t owner) {
7109         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
7110         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
7111         uint64_t ret_ref = 0;
7112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7113         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7114         return ret_ref;
7115 }
7116
7117 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7118         LDKDecodeError ret = *owner->contents.err;
7119         ret.is_owned = false;
7120         return ret;
7121 }
7122 uint64_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint64_t owner) {
7123         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
7124         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
7125         uint64_t ret_ref = 0;
7126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7127         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7128         return ret_ref;
7129 }
7130
7131 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7132         LDKUpdateFailMalformedHTLC ret = *owner->contents.result;
7133         ret.is_owned = false;
7134         return ret;
7135 }
7136 uint64_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint64_t owner) {
7137         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
7138         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
7139         uint64_t ret_ref = 0;
7140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7141         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7142         return ret_ref;
7143 }
7144
7145 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7146         LDKDecodeError ret = *owner->contents.err;
7147         ret.is_owned = false;
7148         return ret;
7149 }
7150 uint64_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint64_t owner) {
7151         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
7152         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
7153         uint64_t ret_ref = 0;
7154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7155         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7156         return ret_ref;
7157 }
7158
7159 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7160         LDKUpdateFee ret = *owner->contents.result;
7161         ret.is_owned = false;
7162         return ret;
7163 }
7164 uint64_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint64_t owner) {
7165         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
7166         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
7167         uint64_t ret_ref = 0;
7168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7169         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7170         return ret_ref;
7171 }
7172
7173 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7174         LDKDecodeError ret = *owner->contents.err;
7175         ret.is_owned = false;
7176         return ret;
7177 }
7178 uint64_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint64_t owner) {
7179         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
7180         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
7181         uint64_t ret_ref = 0;
7182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7183         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7184         return ret_ref;
7185 }
7186
7187 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7188         LDKUpdateFulfillHTLC ret = *owner->contents.result;
7189         ret.is_owned = false;
7190         return ret;
7191 }
7192 uint64_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint64_t owner) {
7193         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
7194         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
7195         uint64_t ret_ref = 0;
7196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7197         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7198         return ret_ref;
7199 }
7200
7201 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7202         LDKDecodeError ret = *owner->contents.err;
7203         ret.is_owned = false;
7204         return ret;
7205 }
7206 uint64_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint64_t owner) {
7207         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
7208         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
7209         uint64_t ret_ref = 0;
7210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7211         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7212         return ret_ref;
7213 }
7214
7215 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7216         LDKUpdateAddHTLC ret = *owner->contents.result;
7217         ret.is_owned = false;
7218         return ret;
7219 }
7220 uint64_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint64_t owner) {
7221         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
7222         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
7223         uint64_t ret_ref = 0;
7224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7225         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7226         return ret_ref;
7227 }
7228
7229 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7230         LDKDecodeError ret = *owner->contents.err;
7231         ret.is_owned = false;
7232         return ret;
7233 }
7234 uint64_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint64_t owner) {
7235         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
7236         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
7237         uint64_t ret_ref = 0;
7238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7239         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7240         return ret_ref;
7241 }
7242
7243 static inline struct LDKOnionMessage CResult_OnionMessageDecodeErrorZ_get_ok(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
7244         LDKOnionMessage ret = *owner->contents.result;
7245         ret.is_owned = false;
7246         return ret;
7247 }
7248 uint64_t  __attribute__((export_name("TS_CResult_OnionMessageDecodeErrorZ_get_ok"))) TS_CResult_OnionMessageDecodeErrorZ_get_ok(uint64_t owner) {
7249         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
7250         LDKOnionMessage ret_var = CResult_OnionMessageDecodeErrorZ_get_ok(owner_conv);
7251         uint64_t ret_ref = 0;
7252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7253         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7254         return ret_ref;
7255 }
7256
7257 static inline struct LDKDecodeError CResult_OnionMessageDecodeErrorZ_get_err(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
7258         LDKDecodeError ret = *owner->contents.err;
7259         ret.is_owned = false;
7260         return ret;
7261 }
7262 uint64_t  __attribute__((export_name("TS_CResult_OnionMessageDecodeErrorZ_get_err"))) TS_CResult_OnionMessageDecodeErrorZ_get_err(uint64_t owner) {
7263         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
7264         LDKDecodeError ret_var = CResult_OnionMessageDecodeErrorZ_get_err(owner_conv);
7265         uint64_t ret_ref = 0;
7266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7267         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7268         return ret_ref;
7269 }
7270
7271 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7272         LDKPing ret = *owner->contents.result;
7273         ret.is_owned = false;
7274         return ret;
7275 }
7276 uint64_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint64_t owner) {
7277         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
7278         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
7279         uint64_t ret_ref = 0;
7280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7281         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7282         return ret_ref;
7283 }
7284
7285 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7286         LDKDecodeError ret = *owner->contents.err;
7287         ret.is_owned = false;
7288         return ret;
7289 }
7290 uint64_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint64_t owner) {
7291         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
7292         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
7293         uint64_t ret_ref = 0;
7294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7295         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7296         return ret_ref;
7297 }
7298
7299 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7300         LDKPong ret = *owner->contents.result;
7301         ret.is_owned = false;
7302         return ret;
7303 }
7304 uint64_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint64_t owner) {
7305         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
7306         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
7307         uint64_t ret_ref = 0;
7308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7309         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7310         return ret_ref;
7311 }
7312
7313 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7314         LDKDecodeError ret = *owner->contents.err;
7315         ret.is_owned = false;
7316         return ret;
7317 }
7318 uint64_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint64_t owner) {
7319         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
7320         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
7321         uint64_t ret_ref = 0;
7322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7323         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7324         return ret_ref;
7325 }
7326
7327 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7328         LDKUnsignedChannelAnnouncement ret = *owner->contents.result;
7329         ret.is_owned = false;
7330         return ret;
7331 }
7332 uint64_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint64_t owner) {
7333         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
7334         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7335         uint64_t ret_ref = 0;
7336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7337         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7338         return ret_ref;
7339 }
7340
7341 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7342         LDKDecodeError ret = *owner->contents.err;
7343         ret.is_owned = false;
7344         return ret;
7345 }
7346 uint64_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint64_t owner) {
7347         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
7348         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7349         uint64_t ret_ref = 0;
7350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7351         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7352         return ret_ref;
7353 }
7354
7355 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7356         LDKChannelAnnouncement ret = *owner->contents.result;
7357         ret.is_owned = false;
7358         return ret;
7359 }
7360 uint64_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint64_t owner) {
7361         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
7362         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7363         uint64_t ret_ref = 0;
7364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7366         return ret_ref;
7367 }
7368
7369 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7370         LDKDecodeError ret = *owner->contents.err;
7371         ret.is_owned = false;
7372         return ret;
7373 }
7374 uint64_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint64_t owner) {
7375         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
7376         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7377         uint64_t ret_ref = 0;
7378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7379         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7380         return ret_ref;
7381 }
7382
7383 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7384         LDKUnsignedChannelUpdate ret = *owner->contents.result;
7385         ret.is_owned = false;
7386         return ret;
7387 }
7388 uint64_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint64_t owner) {
7389         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
7390         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7391         uint64_t ret_ref = 0;
7392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7393         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7394         return ret_ref;
7395 }
7396
7397 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7398         LDKDecodeError ret = *owner->contents.err;
7399         ret.is_owned = false;
7400         return ret;
7401 }
7402 uint64_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint64_t owner) {
7403         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
7404         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
7405         uint64_t ret_ref = 0;
7406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7407         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7408         return ret_ref;
7409 }
7410
7411 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7412         LDKChannelUpdate ret = *owner->contents.result;
7413         ret.is_owned = false;
7414         return ret;
7415 }
7416 uint64_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint64_t owner) {
7417         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
7418         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7419         uint64_t ret_ref = 0;
7420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7421         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7422         return ret_ref;
7423 }
7424
7425 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7426         LDKDecodeError ret = *owner->contents.err;
7427         ret.is_owned = false;
7428         return ret;
7429 }
7430 uint64_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint64_t owner) {
7431         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
7432         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
7433         uint64_t ret_ref = 0;
7434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7435         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7436         return ret_ref;
7437 }
7438
7439 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7440         LDKErrorMessage ret = *owner->contents.result;
7441         ret.is_owned = false;
7442         return ret;
7443 }
7444 uint64_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint64_t owner) {
7445         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
7446         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
7447         uint64_t ret_ref = 0;
7448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7449         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7450         return ret_ref;
7451 }
7452
7453 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7454         LDKDecodeError ret = *owner->contents.err;
7455         ret.is_owned = false;
7456         return ret;
7457 }
7458 uint64_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint64_t owner) {
7459         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
7460         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
7461         uint64_t ret_ref = 0;
7462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7463         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7464         return ret_ref;
7465 }
7466
7467 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7468         LDKWarningMessage ret = *owner->contents.result;
7469         ret.is_owned = false;
7470         return ret;
7471 }
7472 uint64_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_ok"))) TS_CResult_WarningMessageDecodeErrorZ_get_ok(uint64_t owner) {
7473         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
7474         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
7475         uint64_t ret_ref = 0;
7476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7477         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7478         return ret_ref;
7479 }
7480
7481 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7482         LDKDecodeError ret = *owner->contents.err;
7483         ret.is_owned = false;
7484         return ret;
7485 }
7486 uint64_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_err"))) TS_CResult_WarningMessageDecodeErrorZ_get_err(uint64_t owner) {
7487         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
7488         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
7489         uint64_t ret_ref = 0;
7490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7491         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7492         return ret_ref;
7493 }
7494
7495 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7496         LDKUnsignedNodeAnnouncement ret = *owner->contents.result;
7497         ret.is_owned = false;
7498         return ret;
7499 }
7500 uint64_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint64_t owner) {
7501         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
7502         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7503         uint64_t ret_ref = 0;
7504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7505         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7506         return ret_ref;
7507 }
7508
7509 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7510         LDKDecodeError ret = *owner->contents.err;
7511         ret.is_owned = false;
7512         return ret;
7513 }
7514 uint64_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint64_t owner) {
7515         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
7516         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7517         uint64_t ret_ref = 0;
7518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7519         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7520         return ret_ref;
7521 }
7522
7523 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7524         LDKNodeAnnouncement ret = *owner->contents.result;
7525         ret.is_owned = false;
7526         return ret;
7527 }
7528 uint64_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint64_t owner) {
7529         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
7530         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7531         uint64_t ret_ref = 0;
7532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7533         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7534         return ret_ref;
7535 }
7536
7537 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7538         LDKDecodeError ret = *owner->contents.err;
7539         ret.is_owned = false;
7540         return ret;
7541 }
7542 uint64_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint64_t owner) {
7543         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
7544         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7545         uint64_t ret_ref = 0;
7546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7548         return ret_ref;
7549 }
7550
7551 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7552         LDKQueryShortChannelIds ret = *owner->contents.result;
7553         ret.is_owned = false;
7554         return ret;
7555 }
7556 uint64_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint64_t owner) {
7557         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
7558         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
7559         uint64_t ret_ref = 0;
7560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7561         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7562         return ret_ref;
7563 }
7564
7565 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7566         LDKDecodeError ret = *owner->contents.err;
7567         ret.is_owned = false;
7568         return ret;
7569 }
7570 uint64_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint64_t owner) {
7571         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
7572         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
7573         uint64_t ret_ref = 0;
7574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7575         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7576         return ret_ref;
7577 }
7578
7579 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7580         LDKReplyShortChannelIdsEnd ret = *owner->contents.result;
7581         ret.is_owned = false;
7582         return ret;
7583 }
7584 uint64_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint64_t owner) {
7585         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
7586         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
7587         uint64_t ret_ref = 0;
7588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7589         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7590         return ret_ref;
7591 }
7592
7593 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7594         LDKDecodeError ret = *owner->contents.err;
7595         ret.is_owned = false;
7596         return ret;
7597 }
7598 uint64_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint64_t owner) {
7599         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
7600         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
7601         uint64_t ret_ref = 0;
7602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7603         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7604         return ret_ref;
7605 }
7606
7607 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7608         LDKQueryChannelRange ret = *owner->contents.result;
7609         ret.is_owned = false;
7610         return ret;
7611 }
7612 uint64_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint64_t owner) {
7613         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
7614         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
7615         uint64_t ret_ref = 0;
7616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7617         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7618         return ret_ref;
7619 }
7620
7621 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7622         LDKDecodeError ret = *owner->contents.err;
7623         ret.is_owned = false;
7624         return ret;
7625 }
7626 uint64_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint64_t owner) {
7627         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
7628         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
7629         uint64_t ret_ref = 0;
7630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7631         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7632         return ret_ref;
7633 }
7634
7635 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7636         LDKReplyChannelRange ret = *owner->contents.result;
7637         ret.is_owned = false;
7638         return ret;
7639 }
7640 uint64_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint64_t owner) {
7641         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
7642         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
7643         uint64_t ret_ref = 0;
7644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7645         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7646         return ret_ref;
7647 }
7648
7649 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7650         LDKDecodeError ret = *owner->contents.err;
7651         ret.is_owned = false;
7652         return ret;
7653 }
7654 uint64_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint64_t owner) {
7655         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
7656         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
7657         uint64_t ret_ref = 0;
7658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7659         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7660         return ret_ref;
7661 }
7662
7663 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7664         LDKGossipTimestampFilter ret = *owner->contents.result;
7665         ret.is_owned = false;
7666         return ret;
7667 }
7668 uint64_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint64_t owner) {
7669         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
7670         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
7671         uint64_t ret_ref = 0;
7672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7673         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7674         return ret_ref;
7675 }
7676
7677 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7678         LDKDecodeError ret = *owner->contents.err;
7679         ret.is_owned = false;
7680         return ret;
7681 }
7682 uint64_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint64_t owner) {
7683         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
7684         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
7685         uint64_t ret_ref = 0;
7686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7687         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7688         return ret_ref;
7689 }
7690
7691 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_ty_from_ptr"))) TS_LDKSignOrCreationError_ty_from_ptr(uint64_t ptr) {
7692         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
7693         switch(obj->tag) {
7694                 case LDKSignOrCreationError_SignError: return 0;
7695                 case LDKSignOrCreationError_CreationError: return 1;
7696                 default: abort();
7697         }
7698 }
7699 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_CreationError_get_creation_error"))) TS_LDKSignOrCreationError_CreationError_get_creation_error(uint64_t ptr) {
7700         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
7701         assert(obj->tag == LDKSignOrCreationError_CreationError);
7702                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
7703         return creation_error_conv;
7704 }
7705 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7706         LDKInvoice ret = *owner->contents.result;
7707         ret.is_owned = false;
7708         return ret;
7709 }
7710 uint64_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_ok(uint64_t owner) {
7711         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
7712         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
7713         uint64_t ret_ref = 0;
7714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7715         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7716         return ret_ref;
7717 }
7718
7719 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7720 CHECK(!owner->result_ok);
7721         return SignOrCreationError_clone(&*owner->contents.err);
7722 }
7723 uint64_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_err(uint64_t owner) {
7724         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
7725         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
7726         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
7727         uint64_t ret_ref = tag_ptr(ret_copy, true);
7728         return ret_ref;
7729 }
7730
7731 typedef struct LDKFilter_JCalls {
7732         atomic_size_t refcnt;
7733         uint32_t instance_ptr;
7734 } LDKFilter_JCalls;
7735 static void LDKFilter_JCalls_free(void* this_arg) {
7736         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7737         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7738                 FREE(j_calls);
7739         }
7740 }
7741 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7742         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7743         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
7744         memcpy(txid_arr->elems, *txid, 32);
7745         LDKu8slice script_pubkey_var = script_pubkey;
7746         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
7747         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
7748         js_invoke_function_uuuuuu(j_calls->instance_ptr, 33, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr, 0, 0, 0, 0);
7749 }
7750 void register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7751         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7752         LDKWatchedOutput output_var = output;
7753         uint64_t output_ref = 0;
7754         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
7755         output_ref = tag_ptr(output_var.inner, output_var.is_owned);
7756         js_invoke_function_buuuuu(j_calls->instance_ptr, 34, output_ref, 0, 0, 0, 0, 0);
7757 }
7758 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7759         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7760         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7761 }
7762 static inline LDKFilter LDKFilter_init (JSValue o) {
7763         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7764         atomic_init(&calls->refcnt, 1);
7765         calls->instance_ptr = o;
7766
7767         LDKFilter ret = {
7768                 .this_arg = (void*) calls,
7769                 .register_tx = register_tx_LDKFilter_jcall,
7770                 .register_output = register_output_LDKFilter_jcall,
7771                 .free = LDKFilter_JCalls_free,
7772         };
7773         return ret;
7774 }
7775 uint64_t  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
7776         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7777         *res_ptr = LDKFilter_init(o);
7778         return tag_ptr(res_ptr, true);
7779 }
7780 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint64_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
7781         void* this_arg_ptr = untag_ptr(this_arg);
7782         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7783         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7784         unsigned char txid_arr[32];
7785         CHECK(txid->arr_len == 32);
7786         memcpy(txid_arr, txid->elems, 32); FREE(txid);
7787         unsigned char (*txid_ref)[32] = &txid_arr;
7788         LDKu8slice script_pubkey_ref;
7789         script_pubkey_ref.datalen = script_pubkey->arr_len;
7790         script_pubkey_ref.data = script_pubkey->elems;
7791         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7792         FREE(script_pubkey);
7793 }
7794
7795 void  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint64_t this_arg, uint64_t output) {
7796         void* this_arg_ptr = untag_ptr(this_arg);
7797         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7798         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7799         LDKWatchedOutput output_conv;
7800         output_conv.inner = untag_ptr(output);
7801         output_conv.is_owned = ptr_is_owned(output);
7802         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
7803         output_conv = WatchedOutput_clone(&output_conv);
7804         (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7805 }
7806
7807 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint64_t ptr) {
7808         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
7809         switch(obj->tag) {
7810                 case LDKCOption_FilterZ_Some: return 0;
7811                 case LDKCOption_FilterZ_None: return 1;
7812                 default: abort();
7813         }
7814 }
7815 uint64_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint64_t ptr) {
7816         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
7817         assert(obj->tag == LDKCOption_FilterZ_Some);
7818                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
7819                         *some_ret = obj->some;
7820                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
7821                         if ((*some_ret).free == LDKFilter_JCalls_free) {
7822                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7823                                 LDKFilter_JCalls_cloned(&(*some_ret));
7824                         }
7825         return tag_ptr(some_ret, true);
7826 }
7827 static inline struct LDKLockedChannelMonitor CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
7828         LDKLockedChannelMonitor ret = *owner->contents.result;
7829         ret.is_owned = false;
7830         return ret;
7831 }
7832 uint64_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint64_t owner) {
7833         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
7834         LDKLockedChannelMonitor ret_var = CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
7835         uint64_t ret_ref = 0;
7836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7837         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7838         return ret_ref;
7839 }
7840
7841 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
7842 CHECK(!owner->result_ok);
7843         return *owner->contents.err;
7844 }
7845 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint64_t owner) {
7846         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
7847         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
7848 }
7849
7850 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
7851         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
7852         for (size_t i = 0; i < ret.datalen; i++) {
7853                 ret.data[i] = OutPoint_clone(&orig->data[i]);
7854         }
7855         return ret;
7856 }
7857 typedef struct LDKMessageSendEventsProvider_JCalls {
7858         atomic_size_t refcnt;
7859         uint32_t instance_ptr;
7860 } LDKMessageSendEventsProvider_JCalls;
7861 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
7862         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7863         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7864                 FREE(j_calls);
7865         }
7866 }
7867 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
7868         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7869         uint64_tArray ret = (uint64_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 35, 0, 0, 0, 0, 0, 0);
7870         LDKCVec_MessageSendEventZ ret_constr;
7871         ret_constr.datalen = ret->arr_len;
7872         if (ret_constr.datalen > 0)
7873                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7874         else
7875                 ret_constr.data = NULL;
7876         uint64_t* ret_vals = ret->elems;
7877         for (size_t s = 0; s < ret_constr.datalen; s++) {
7878                 uint64_t ret_conv_18 = ret_vals[s];
7879                 void* ret_conv_18_ptr = untag_ptr(ret_conv_18);
7880                 CHECK_ACCESS(ret_conv_18_ptr);
7881                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
7882                 FREE(untag_ptr(ret_conv_18));
7883                 ret_constr.data[s] = ret_conv_18_conv;
7884         }
7885         FREE(ret);
7886         return ret_constr;
7887 }
7888 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
7889         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
7890         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7891 }
7892 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
7893         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
7894         atomic_init(&calls->refcnt, 1);
7895         calls->instance_ptr = o;
7896
7897         LDKMessageSendEventsProvider ret = {
7898                 .this_arg = (void*) calls,
7899                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
7900                 .free = LDKMessageSendEventsProvider_JCalls_free,
7901         };
7902         return ret;
7903 }
7904 uint64_t  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
7905         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
7906         *res_ptr = LDKMessageSendEventsProvider_init(o);
7907         return tag_ptr(res_ptr, true);
7908 }
7909 uint64_tArray  __attribute__((export_name("TS_MessageSendEventsProvider_get_and_clear_pending_msg_events"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint64_t this_arg) {
7910         void* this_arg_ptr = untag_ptr(this_arg);
7911         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7912         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
7913         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
7914         uint64_tArray ret_arr = NULL;
7915         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
7916         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
7917         for (size_t s = 0; s < ret_var.datalen; s++) {
7918                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
7919                 *ret_conv_18_copy = ret_var.data[s];
7920                 uint64_t ret_conv_18_ref = tag_ptr(ret_conv_18_copy, true);
7921                 ret_arr_ptr[s] = ret_conv_18_ref;
7922         }
7923         
7924         FREE(ret_var.data);
7925         return ret_arr;
7926 }
7927
7928 typedef struct LDKOnionMessageProvider_JCalls {
7929         atomic_size_t refcnt;
7930         uint32_t instance_ptr;
7931 } LDKOnionMessageProvider_JCalls;
7932 static void LDKOnionMessageProvider_JCalls_free(void* this_arg) {
7933         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
7934         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7935                 FREE(j_calls);
7936         }
7937 }
7938 LDKOnionMessage next_onion_message_for_peer_LDKOnionMessageProvider_jcall(const void* this_arg, LDKPublicKey peer_node_id) {
7939         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
7940         int8_tArray peer_node_id_arr = init_int8_tArray(33, __LINE__);
7941         memcpy(peer_node_id_arr->elems, peer_node_id.compressed_form, 33);
7942         uint64_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 36, (uint32_t)peer_node_id_arr, 0, 0, 0, 0, 0);
7943         LDKOnionMessage ret_conv;
7944         ret_conv.inner = untag_ptr(ret);
7945         ret_conv.is_owned = ptr_is_owned(ret);
7946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
7947         return ret_conv;
7948 }
7949 static void LDKOnionMessageProvider_JCalls_cloned(LDKOnionMessageProvider* new_obj) {
7950         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) new_obj->this_arg;
7951         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7952 }
7953 static inline LDKOnionMessageProvider LDKOnionMessageProvider_init (JSValue o) {
7954         LDKOnionMessageProvider_JCalls *calls = MALLOC(sizeof(LDKOnionMessageProvider_JCalls), "LDKOnionMessageProvider_JCalls");
7955         atomic_init(&calls->refcnt, 1);
7956         calls->instance_ptr = o;
7957
7958         LDKOnionMessageProvider ret = {
7959                 .this_arg = (void*) calls,
7960                 .next_onion_message_for_peer = next_onion_message_for_peer_LDKOnionMessageProvider_jcall,
7961                 .free = LDKOnionMessageProvider_JCalls_free,
7962         };
7963         return ret;
7964 }
7965 uint64_t  __attribute__((export_name("TS_LDKOnionMessageProvider_new"))) TS_LDKOnionMessageProvider_new(JSValue o) {
7966         LDKOnionMessageProvider *res_ptr = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
7967         *res_ptr = LDKOnionMessageProvider_init(o);
7968         return tag_ptr(res_ptr, true);
7969 }
7970 uint64_t  __attribute__((export_name("TS_OnionMessageProvider_next_onion_message_for_peer"))) TS_OnionMessageProvider_next_onion_message_for_peer(uint64_t this_arg, int8_tArray peer_node_id) {
7971         void* this_arg_ptr = untag_ptr(this_arg);
7972         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7973         LDKOnionMessageProvider* this_arg_conv = (LDKOnionMessageProvider*)this_arg_ptr;
7974         LDKPublicKey peer_node_id_ref;
7975         CHECK(peer_node_id->arr_len == 33);
7976         memcpy(peer_node_id_ref.compressed_form, peer_node_id->elems, 33); FREE(peer_node_id);
7977         LDKOnionMessage ret_var = (this_arg_conv->next_onion_message_for_peer)(this_arg_conv->this_arg, peer_node_id_ref);
7978         uint64_t ret_ref = 0;
7979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7980         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7981         return ret_ref;
7982 }
7983
7984 typedef struct LDKEventHandler_JCalls {
7985         atomic_size_t refcnt;
7986         uint32_t instance_ptr;
7987 } LDKEventHandler_JCalls;
7988 static void LDKEventHandler_JCalls_free(void* this_arg) {
7989         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7990         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7991                 FREE(j_calls);
7992         }
7993 }
7994 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
7995         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7996         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
7997         *ret_event = Event_clone(event);
7998         uint64_t ref_event = tag_ptr(ret_event, true);
7999         js_invoke_function_buuuuu(j_calls->instance_ptr, 37, ref_event, 0, 0, 0, 0, 0);
8000 }
8001 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
8002         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
8003         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8004 }
8005 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
8006         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
8007         atomic_init(&calls->refcnt, 1);
8008         calls->instance_ptr = o;
8009
8010         LDKEventHandler ret = {
8011                 .this_arg = (void*) calls,
8012                 .handle_event = handle_event_LDKEventHandler_jcall,
8013                 .free = LDKEventHandler_JCalls_free,
8014         };
8015         return ret;
8016 }
8017 uint64_t  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
8018         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8019         *res_ptr = LDKEventHandler_init(o);
8020         return tag_ptr(res_ptr, true);
8021 }
8022 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint64_t this_arg, uint64_t event) {
8023         void* this_arg_ptr = untag_ptr(this_arg);
8024         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8025         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
8026         LDKEvent* event_conv = (LDKEvent*)untag_ptr(event);
8027         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
8028 }
8029
8030 typedef struct LDKEventsProvider_JCalls {
8031         atomic_size_t refcnt;
8032         uint32_t instance_ptr;
8033 } LDKEventsProvider_JCalls;
8034 static void LDKEventsProvider_JCalls_free(void* this_arg) {
8035         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8036         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8037                 FREE(j_calls);
8038         }
8039 }
8040 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
8041         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8042         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8043         *handler_ret = handler;
8044         js_invoke_function_buuuuu(j_calls->instance_ptr, 38, tag_ptr(handler_ret, true), 0, 0, 0, 0, 0);
8045 }
8046 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
8047         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
8048         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8049 }
8050 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
8051         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
8052         atomic_init(&calls->refcnt, 1);
8053         calls->instance_ptr = o;
8054
8055         LDKEventsProvider ret = {
8056                 .this_arg = (void*) calls,
8057                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
8058                 .free = LDKEventsProvider_JCalls_free,
8059         };
8060         return ret;
8061 }
8062 uint64_t  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
8063         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8064         *res_ptr = LDKEventsProvider_init(o);
8065         return tag_ptr(res_ptr, true);
8066 }
8067 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint64_t this_arg, uint64_t handler) {
8068         void* this_arg_ptr = untag_ptr(this_arg);
8069         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8070         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
8071         void* handler_ptr = untag_ptr(handler);
8072         CHECK_ACCESS(handler_ptr);
8073         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
8074         if (handler_conv.free == LDKEventHandler_JCalls_free) {
8075                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8076                 LDKEventHandler_JCalls_cloned(&handler_conv);
8077         }
8078         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
8079 }
8080
8081 typedef struct LDKScore_JCalls {
8082         atomic_size_t refcnt;
8083         uint32_t instance_ptr;
8084 } LDKScore_JCalls;
8085 static void LDKScore_JCalls_free(void* this_arg) {
8086         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8087         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8088                 FREE(j_calls);
8089         }
8090 }
8091 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
8092         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8093         int64_t short_channel_id_conv = short_channel_id;
8094         LDKNodeId source_var = *source;
8095         uint64_t source_ref = 0;
8096         source_var = NodeId_clone(&source_var);
8097         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
8098         source_ref = tag_ptr(source_var.inner, source_var.is_owned);
8099         LDKNodeId target_var = *target;
8100         uint64_t target_ref = 0;
8101         target_var = NodeId_clone(&target_var);
8102         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
8103         target_ref = tag_ptr(target_var.inner, target_var.is_owned);
8104         LDKChannelUsage usage_var = usage;
8105         uint64_t usage_ref = 0;
8106         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
8107         usage_ref = tag_ptr(usage_var.inner, usage_var.is_owned);
8108         return js_invoke_function_bbbbuu(j_calls->instance_ptr, 39, short_channel_id_conv, source_ref, target_ref, usage_ref, 0, 0);
8109 }
8110 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
8111         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8112         LDKCVec_RouteHopZ path_var = path;
8113         uint64_tArray path_arr = NULL;
8114         path_arr = init_uint64_tArray(path_var.datalen, __LINE__);
8115         uint64_t *path_arr_ptr = (uint64_t*)(((uint8_t*)path_arr) + 8);
8116         for (size_t k = 0; k < path_var.datalen; k++) {
8117                 LDKRouteHop path_conv_10_var = path_var.data[k];
8118                 uint64_t path_conv_10_ref = 0;
8119                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8120                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
8121                 path_arr_ptr[k] = path_conv_10_ref;
8122         }
8123         
8124         FREE(path_var.data);
8125         int64_t short_channel_id_conv = short_channel_id;
8126         js_invoke_function_ubuuuu(j_calls->instance_ptr, 40, (uint32_t)path_arr, short_channel_id_conv, 0, 0, 0, 0);
8127 }
8128 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
8129         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8130         LDKCVec_RouteHopZ path_var = path;
8131         uint64_tArray path_arr = NULL;
8132         path_arr = init_uint64_tArray(path_var.datalen, __LINE__);
8133         uint64_t *path_arr_ptr = (uint64_t*)(((uint8_t*)path_arr) + 8);
8134         for (size_t k = 0; k < path_var.datalen; k++) {
8135                 LDKRouteHop path_conv_10_var = path_var.data[k];
8136                 uint64_t path_conv_10_ref = 0;
8137                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8138                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
8139                 path_arr_ptr[k] = path_conv_10_ref;
8140         }
8141         
8142         FREE(path_var.data);
8143         js_invoke_function_uuuuuu(j_calls->instance_ptr, 41, (uint32_t)path_arr, 0, 0, 0, 0, 0);
8144 }
8145 void probe_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
8146         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8147         LDKCVec_RouteHopZ path_var = path;
8148         uint64_tArray path_arr = NULL;
8149         path_arr = init_uint64_tArray(path_var.datalen, __LINE__);
8150         uint64_t *path_arr_ptr = (uint64_t*)(((uint8_t*)path_arr) + 8);
8151         for (size_t k = 0; k < path_var.datalen; k++) {
8152                 LDKRouteHop path_conv_10_var = path_var.data[k];
8153                 uint64_t path_conv_10_ref = 0;
8154                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8155                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
8156                 path_arr_ptr[k] = path_conv_10_ref;
8157         }
8158         
8159         FREE(path_var.data);
8160         int64_t short_channel_id_conv = short_channel_id;
8161         js_invoke_function_ubuuuu(j_calls->instance_ptr, 42, (uint32_t)path_arr, short_channel_id_conv, 0, 0, 0, 0);
8162 }
8163 void probe_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
8164         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8165         LDKCVec_RouteHopZ path_var = path;
8166         uint64_tArray path_arr = NULL;
8167         path_arr = init_uint64_tArray(path_var.datalen, __LINE__);
8168         uint64_t *path_arr_ptr = (uint64_t*)(((uint8_t*)path_arr) + 8);
8169         for (size_t k = 0; k < path_var.datalen; k++) {
8170                 LDKRouteHop path_conv_10_var = path_var.data[k];
8171                 uint64_t path_conv_10_ref = 0;
8172                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8173                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
8174                 path_arr_ptr[k] = path_conv_10_ref;
8175         }
8176         
8177         FREE(path_var.data);
8178         js_invoke_function_uuuuuu(j_calls->instance_ptr, 43, (uint32_t)path_arr, 0, 0, 0, 0, 0);
8179 }
8180 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
8181         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8182         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 44, 0, 0, 0, 0, 0, 0);
8183         LDKCVec_u8Z ret_ref;
8184         ret_ref.datalen = ret->arr_len;
8185         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8186         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
8187         return ret_ref;
8188 }
8189 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
8190         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
8191         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8192 }
8193 static inline LDKScore LDKScore_init (JSValue o) {
8194         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
8195         atomic_init(&calls->refcnt, 1);
8196         calls->instance_ptr = o;
8197
8198         LDKScore ret = {
8199                 .this_arg = (void*) calls,
8200                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
8201                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
8202                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
8203                 .probe_failed = probe_failed_LDKScore_jcall,
8204                 .probe_successful = probe_successful_LDKScore_jcall,
8205                 .write = write_LDKScore_jcall,
8206                 .free = LDKScore_JCalls_free,
8207         };
8208         return ret;
8209 }
8210 uint64_t  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
8211         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
8212         *res_ptr = LDKScore_init(o);
8213         return tag_ptr(res_ptr, true);
8214 }
8215 int64_t  __attribute__((export_name("TS_Score_channel_penalty_msat"))) TS_Score_channel_penalty_msat(uint64_t this_arg, int64_t short_channel_id, uint64_t source, uint64_t target, uint64_t usage) {
8216         void* this_arg_ptr = untag_ptr(this_arg);
8217         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8218         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8219         LDKNodeId source_conv;
8220         source_conv.inner = untag_ptr(source);
8221         source_conv.is_owned = ptr_is_owned(source);
8222         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
8223         source_conv.is_owned = false;
8224         LDKNodeId target_conv;
8225         target_conv.inner = untag_ptr(target);
8226         target_conv.is_owned = ptr_is_owned(target);
8227         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
8228         target_conv.is_owned = false;
8229         LDKChannelUsage usage_conv;
8230         usage_conv.inner = untag_ptr(usage);
8231         usage_conv.is_owned = ptr_is_owned(usage);
8232         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
8233         usage_conv = ChannelUsage_clone(&usage_conv);
8234         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
8235         return ret_conv;
8236 }
8237
8238 void  __attribute__((export_name("TS_Score_payment_path_failed"))) TS_Score_payment_path_failed(uint64_t this_arg, uint64_tArray path, int64_t short_channel_id) {
8239         void* this_arg_ptr = untag_ptr(this_arg);
8240         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8241         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8242         LDKCVec_RouteHopZ path_constr;
8243         path_constr.datalen = path->arr_len;
8244         if (path_constr.datalen > 0)
8245                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8246         else
8247                 path_constr.data = NULL;
8248         uint64_t* path_vals = path->elems;
8249         for (size_t k = 0; k < path_constr.datalen; k++) {
8250                 uint64_t path_conv_10 = path_vals[k];
8251                 LDKRouteHop path_conv_10_conv;
8252                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
8253                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
8254                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8255                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8256                 path_constr.data[k] = path_conv_10_conv;
8257         }
8258         FREE(path);
8259         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
8260 }
8261
8262 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint64_t this_arg, uint64_tArray path) {
8263         void* this_arg_ptr = untag_ptr(this_arg);
8264         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8265         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8266         LDKCVec_RouteHopZ path_constr;
8267         path_constr.datalen = path->arr_len;
8268         if (path_constr.datalen > 0)
8269                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8270         else
8271                 path_constr.data = NULL;
8272         uint64_t* path_vals = path->elems;
8273         for (size_t k = 0; k < path_constr.datalen; k++) {
8274                 uint64_t path_conv_10 = path_vals[k];
8275                 LDKRouteHop path_conv_10_conv;
8276                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
8277                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
8278                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8279                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8280                 path_constr.data[k] = path_conv_10_conv;
8281         }
8282         FREE(path);
8283         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
8284 }
8285
8286 void  __attribute__((export_name("TS_Score_probe_failed"))) TS_Score_probe_failed(uint64_t this_arg, uint64_tArray path, int64_t short_channel_id) {
8287         void* this_arg_ptr = untag_ptr(this_arg);
8288         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8289         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8290         LDKCVec_RouteHopZ path_constr;
8291         path_constr.datalen = path->arr_len;
8292         if (path_constr.datalen > 0)
8293                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8294         else
8295                 path_constr.data = NULL;
8296         uint64_t* path_vals = path->elems;
8297         for (size_t k = 0; k < path_constr.datalen; k++) {
8298                 uint64_t path_conv_10 = path_vals[k];
8299                 LDKRouteHop path_conv_10_conv;
8300                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
8301                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
8302                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8303                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8304                 path_constr.data[k] = path_conv_10_conv;
8305         }
8306         FREE(path);
8307         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
8308 }
8309
8310 void  __attribute__((export_name("TS_Score_probe_successful"))) TS_Score_probe_successful(uint64_t this_arg, uint64_tArray path) {
8311         void* this_arg_ptr = untag_ptr(this_arg);
8312         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8313         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8314         LDKCVec_RouteHopZ path_constr;
8315         path_constr.datalen = path->arr_len;
8316         if (path_constr.datalen > 0)
8317                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8318         else
8319                 path_constr.data = NULL;
8320         uint64_t* path_vals = path->elems;
8321         for (size_t k = 0; k < path_constr.datalen; k++) {
8322                 uint64_t path_conv_10 = path_vals[k];
8323                 LDKRouteHop path_conv_10_conv;
8324                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
8325                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
8326                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8327                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8328                 path_constr.data[k] = path_conv_10_conv;
8329         }
8330         FREE(path);
8331         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, path_constr);
8332 }
8333
8334 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint64_t this_arg) {
8335         void* this_arg_ptr = untag_ptr(this_arg);
8336         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8337         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8338         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8339         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
8340         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
8341         CVec_u8Z_free(ret_var);
8342         return ret_arr;
8343 }
8344
8345 typedef struct LDKLockableScore_JCalls {
8346         atomic_size_t refcnt;
8347         uint32_t instance_ptr;
8348 } LDKLockableScore_JCalls;
8349 static void LDKLockableScore_JCalls_free(void* this_arg) {
8350         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
8351         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8352                 FREE(j_calls);
8353         }
8354 }
8355 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
8356         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
8357         uint64_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 45, 0, 0, 0, 0, 0, 0);
8358         void* ret_ptr = untag_ptr(ret);
8359         CHECK_ACCESS(ret_ptr);
8360         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
8361         if (ret_conv.free == LDKScore_JCalls_free) {
8362                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8363                 LDKScore_JCalls_cloned(&ret_conv);
8364         }// WARNING: we may need a move here but no clone is available for LDKScore
8365         
8366         return ret_conv;
8367 }
8368 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
8369         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
8370         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8371 }
8372 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
8373         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
8374         atomic_init(&calls->refcnt, 1);
8375         calls->instance_ptr = o;
8376
8377         LDKLockableScore ret = {
8378                 .this_arg = (void*) calls,
8379                 .lock = lock_LDKLockableScore_jcall,
8380                 .free = LDKLockableScore_JCalls_free,
8381         };
8382         return ret;
8383 }
8384 uint64_t  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
8385         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
8386         *res_ptr = LDKLockableScore_init(o);
8387         return tag_ptr(res_ptr, true);
8388 }
8389 uint64_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint64_t this_arg) {
8390         void* this_arg_ptr = untag_ptr(this_arg);
8391         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8392         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
8393         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
8394         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
8395         return tag_ptr(ret_ret, true);
8396 }
8397
8398 typedef struct LDKWriteableScore_JCalls {
8399         atomic_size_t refcnt;
8400         uint32_t instance_ptr;
8401         LDKLockableScore_JCalls* LockableScore;
8402 } LDKWriteableScore_JCalls;
8403 static void LDKWriteableScore_JCalls_free(void* this_arg) {
8404         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
8405         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8406                 FREE(j_calls);
8407         }
8408 }
8409 LDKCVec_u8Z write_LDKWriteableScore_jcall(const void* this_arg) {
8410         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
8411         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 46, 0, 0, 0, 0, 0, 0);
8412         LDKCVec_u8Z ret_ref;
8413         ret_ref.datalen = ret->arr_len;
8414         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8415         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
8416         return ret_ref;
8417 }
8418 static void LDKWriteableScore_JCalls_cloned(LDKWriteableScore* new_obj) {
8419         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) new_obj->this_arg;
8420         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8421         atomic_fetch_add_explicit(&j_calls->LockableScore->refcnt, 1, memory_order_release);
8422 }
8423 static inline LDKWriteableScore LDKWriteableScore_init (JSValue o, JSValue LockableScore) {
8424         LDKWriteableScore_JCalls *calls = MALLOC(sizeof(LDKWriteableScore_JCalls), "LDKWriteableScore_JCalls");
8425         atomic_init(&calls->refcnt, 1);
8426         calls->instance_ptr = o;
8427
8428         LDKWriteableScore ret = {
8429                 .this_arg = (void*) calls,
8430                 .write = write_LDKWriteableScore_jcall,
8431                 .free = LDKWriteableScore_JCalls_free,
8432                 .LockableScore = LDKLockableScore_init(LockableScore),
8433         };
8434         calls->LockableScore = ret.LockableScore.this_arg;
8435         return ret;
8436 }
8437 uint64_t  __attribute__((export_name("TS_LDKWriteableScore_new"))) TS_LDKWriteableScore_new(JSValue o, JSValue LockableScore) {
8438         LDKWriteableScore *res_ptr = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
8439         *res_ptr = LDKWriteableScore_init(o, LockableScore);
8440         return tag_ptr(res_ptr, true);
8441 }
8442 int8_tArray  __attribute__((export_name("TS_WriteableScore_write"))) TS_WriteableScore_write(uint64_t this_arg) {
8443         void* this_arg_ptr = untag_ptr(this_arg);
8444         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8445         LDKWriteableScore* this_arg_conv = (LDKWriteableScore*)this_arg_ptr;
8446         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8447         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
8448         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
8449         CVec_u8Z_free(ret_var);
8450         return ret_arr;
8451 }
8452
8453 typedef struct LDKPersister_JCalls {
8454         atomic_size_t refcnt;
8455         uint32_t instance_ptr;
8456 } LDKPersister_JCalls;
8457 static void LDKPersister_JCalls_free(void* this_arg) {
8458         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8459         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8460                 FREE(j_calls);
8461         }
8462 }
8463 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8464         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8465         LDKChannelManager channel_manager_var = *channel_manager;
8466         uint64_t channel_manager_ref = 0;
8467         // WARNING: we may need a move here but no clone is available for LDKChannelManager
8468         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
8469         channel_manager_ref = tag_ptr(channel_manager_var.inner, channel_manager_var.is_owned);
8470         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 47, channel_manager_ref, 0, 0, 0, 0, 0);
8471         void* ret_ptr = untag_ptr(ret);
8472         CHECK_ACCESS(ret_ptr);
8473         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8474         FREE(untag_ptr(ret));
8475         return ret_conv;
8476 }
8477 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
8478         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8479         LDKNetworkGraph network_graph_var = *network_graph;
8480         uint64_t network_graph_ref = 0;
8481         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
8482         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
8483         network_graph_ref = tag_ptr(network_graph_var.inner, network_graph_var.is_owned);
8484         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 48, network_graph_ref, 0, 0, 0, 0, 0);
8485         void* ret_ptr = untag_ptr(ret);
8486         CHECK_ACCESS(ret_ptr);
8487         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8488         FREE(untag_ptr(ret));
8489         return ret_conv;
8490 }
8491 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKWriteableScore * scorer) {
8492         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8493         // WARNING: This object doesn't live past this scope, needs clone!
8494         uint64_t ret_scorer = tag_ptr(scorer, false);
8495         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 49, ret_scorer, 0, 0, 0, 0, 0);
8496         void* ret_ptr = untag_ptr(ret);
8497         CHECK_ACCESS(ret_ptr);
8498         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8499         FREE(untag_ptr(ret));
8500         return ret_conv;
8501 }
8502 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
8503         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
8504         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8505 }
8506 static inline LDKPersister LDKPersister_init (JSValue o) {
8507         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
8508         atomic_init(&calls->refcnt, 1);
8509         calls->instance_ptr = o;
8510
8511         LDKPersister ret = {
8512                 .this_arg = (void*) calls,
8513                 .persist_manager = persist_manager_LDKPersister_jcall,
8514                 .persist_graph = persist_graph_LDKPersister_jcall,
8515                 .persist_scorer = persist_scorer_LDKPersister_jcall,
8516                 .free = LDKPersister_JCalls_free,
8517         };
8518         return ret;
8519 }
8520 uint64_t  __attribute__((export_name("TS_LDKPersister_new"))) TS_LDKPersister_new(JSValue o) {
8521         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
8522         *res_ptr = LDKPersister_init(o);
8523         return tag_ptr(res_ptr, true);
8524 }
8525 uint64_t  __attribute__((export_name("TS_Persister_persist_manager"))) TS_Persister_persist_manager(uint64_t this_arg, uint64_t channel_manager) {
8526         void* this_arg_ptr = untag_ptr(this_arg);
8527         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8528         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8529         LDKChannelManager channel_manager_conv;
8530         channel_manager_conv.inner = untag_ptr(channel_manager);
8531         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
8532         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
8533         channel_manager_conv.is_owned = false;
8534         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8535         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8536         return tag_ptr(ret_conv, true);
8537 }
8538
8539 uint64_t  __attribute__((export_name("TS_Persister_persist_graph"))) TS_Persister_persist_graph(uint64_t this_arg, uint64_t network_graph) {
8540         void* this_arg_ptr = untag_ptr(this_arg);
8541         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8542         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8543         LDKNetworkGraph network_graph_conv;
8544         network_graph_conv.inner = untag_ptr(network_graph);
8545         network_graph_conv.is_owned = ptr_is_owned(network_graph);
8546         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
8547         network_graph_conv.is_owned = false;
8548         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8549         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
8550         return tag_ptr(ret_conv, true);
8551 }
8552
8553 uint64_t  __attribute__((export_name("TS_Persister_persist_scorer"))) TS_Persister_persist_scorer(uint64_t this_arg, uint64_t scorer) {
8554         void* this_arg_ptr = untag_ptr(this_arg);
8555         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8556         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8557         void* scorer_ptr = untag_ptr(scorer);
8558         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
8559         LDKWriteableScore* scorer_conv = (LDKWriteableScore*)scorer_ptr;
8560         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8561         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, scorer_conv);
8562         return tag_ptr(ret_conv, true);
8563 }
8564
8565 typedef struct LDKFutureCallback_JCalls {
8566         atomic_size_t refcnt;
8567         uint32_t instance_ptr;
8568 } LDKFutureCallback_JCalls;
8569 static void LDKFutureCallback_JCalls_free(void* this_arg) {
8570         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
8571         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8572                 FREE(j_calls);
8573         }
8574 }
8575 void call_LDKFutureCallback_jcall(const void* this_arg) {
8576         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
8577         js_invoke_function_uuuuuu(j_calls->instance_ptr, 50, 0, 0, 0, 0, 0, 0);
8578 }
8579 static void LDKFutureCallback_JCalls_cloned(LDKFutureCallback* new_obj) {
8580         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) new_obj->this_arg;
8581         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8582 }
8583 static inline LDKFutureCallback LDKFutureCallback_init (JSValue o) {
8584         LDKFutureCallback_JCalls *calls = MALLOC(sizeof(LDKFutureCallback_JCalls), "LDKFutureCallback_JCalls");
8585         atomic_init(&calls->refcnt, 1);
8586         calls->instance_ptr = o;
8587
8588         LDKFutureCallback ret = {
8589                 .this_arg = (void*) calls,
8590                 .call = call_LDKFutureCallback_jcall,
8591                 .free = LDKFutureCallback_JCalls_free,
8592         };
8593         return ret;
8594 }
8595 uint64_t  __attribute__((export_name("TS_LDKFutureCallback_new"))) TS_LDKFutureCallback_new(JSValue o) {
8596         LDKFutureCallback *res_ptr = MALLOC(sizeof(LDKFutureCallback), "LDKFutureCallback");
8597         *res_ptr = LDKFutureCallback_init(o);
8598         return tag_ptr(res_ptr, true);
8599 }
8600 void  __attribute__((export_name("TS_FutureCallback_call"))) TS_FutureCallback_call(uint64_t this_arg) {
8601         void* this_arg_ptr = untag_ptr(this_arg);
8602         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8603         LDKFutureCallback* this_arg_conv = (LDKFutureCallback*)this_arg_ptr;
8604         (this_arg_conv->call)(this_arg_conv->this_arg);
8605 }
8606
8607 typedef struct LDKListen_JCalls {
8608         atomic_size_t refcnt;
8609         uint32_t instance_ptr;
8610 } LDKListen_JCalls;
8611 static void LDKListen_JCalls_free(void* this_arg) {
8612         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8613         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8614                 FREE(j_calls);
8615         }
8616 }
8617 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8618         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8619         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8620         memcpy(header_arr->elems, *header, 80);
8621         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8622         uint64_tArray txdata_arr = NULL;
8623         txdata_arr = init_uint64_tArray(txdata_var.datalen, __LINE__);
8624         uint64_t *txdata_arr_ptr = (uint64_t*)(((uint8_t*)txdata_arr) + 8);
8625         for (size_t c = 0; c < txdata_var.datalen; c++) {
8626                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8627                 *txdata_conv_28_conv = txdata_var.data[c];
8628                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
8629         }
8630         
8631         FREE(txdata_var.data);
8632         int32_t height_conv = height;
8633         js_invoke_function_uuuuuu(j_calls->instance_ptr, 51, (uint32_t)header_arr, (uint32_t)txdata_arr, height_conv, 0, 0, 0);
8634 }
8635 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
8636         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8637         LDKu8slice block_var = block;
8638         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
8639         memcpy(block_arr->elems, block_var.data, block_var.datalen);
8640         int32_t height_conv = height;
8641         js_invoke_function_uuuuuu(j_calls->instance_ptr, 52, (uint32_t)block_arr, height_conv, 0, 0, 0, 0);
8642 }
8643 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8644         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8645         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8646         memcpy(header_arr->elems, *header, 80);
8647         int32_t height_conv = height;
8648         js_invoke_function_uuuuuu(j_calls->instance_ptr, 53, (uint32_t)header_arr, height_conv, 0, 0, 0, 0);
8649 }
8650 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
8651         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
8652         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8653 }
8654 static inline LDKListen LDKListen_init (JSValue o) {
8655         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
8656         atomic_init(&calls->refcnt, 1);
8657         calls->instance_ptr = o;
8658
8659         LDKListen ret = {
8660                 .this_arg = (void*) calls,
8661                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
8662                 .block_connected = block_connected_LDKListen_jcall,
8663                 .block_disconnected = block_disconnected_LDKListen_jcall,
8664                 .free = LDKListen_JCalls_free,
8665         };
8666         return ret;
8667 }
8668 uint64_t  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
8669         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
8670         *res_ptr = LDKListen_init(o);
8671         return tag_ptr(res_ptr, true);
8672 }
8673 void  __attribute__((export_name("TS_Listen_filtered_block_connected"))) TS_Listen_filtered_block_connected(uint64_t this_arg, int8_tArray header, uint64_tArray txdata, int32_t height) {
8674         void* this_arg_ptr = untag_ptr(this_arg);
8675         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8676         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8677         unsigned char header_arr[80];
8678         CHECK(header->arr_len == 80);
8679         memcpy(header_arr, header->elems, 80); FREE(header);
8680         unsigned char (*header_ref)[80] = &header_arr;
8681         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8682         txdata_constr.datalen = txdata->arr_len;
8683         if (txdata_constr.datalen > 0)
8684                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8685         else
8686                 txdata_constr.data = NULL;
8687         uint64_t* txdata_vals = txdata->elems;
8688         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8689                 uint64_t txdata_conv_28 = txdata_vals[c];
8690                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
8691                 CHECK_ACCESS(txdata_conv_28_ptr);
8692                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8693                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
8694                 txdata_constr.data[c] = txdata_conv_28_conv;
8695         }
8696         FREE(txdata);
8697         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8698 }
8699
8700 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint64_t this_arg, int8_tArray block, int32_t height) {
8701         void* this_arg_ptr = untag_ptr(this_arg);
8702         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8703         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8704         LDKu8slice block_ref;
8705         block_ref.datalen = block->arr_len;
8706         block_ref.data = block->elems;
8707         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
8708         FREE(block);
8709 }
8710
8711 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint64_t this_arg, int8_tArray header, int32_t height) {
8712         void* this_arg_ptr = untag_ptr(this_arg);
8713         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8714         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8715         unsigned char header_arr[80];
8716         CHECK(header->arr_len == 80);
8717         memcpy(header_arr, header->elems, 80); FREE(header);
8718         unsigned char (*header_ref)[80] = &header_arr;
8719         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
8720 }
8721
8722 typedef struct LDKConfirm_JCalls {
8723         atomic_size_t refcnt;
8724         uint32_t instance_ptr;
8725 } LDKConfirm_JCalls;
8726 static void LDKConfirm_JCalls_free(void* this_arg) {
8727         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8728         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8729                 FREE(j_calls);
8730         }
8731 }
8732 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8733         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8734         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8735         memcpy(header_arr->elems, *header, 80);
8736         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8737         uint64_tArray txdata_arr = NULL;
8738         txdata_arr = init_uint64_tArray(txdata_var.datalen, __LINE__);
8739         uint64_t *txdata_arr_ptr = (uint64_t*)(((uint8_t*)txdata_arr) + 8);
8740         for (size_t c = 0; c < txdata_var.datalen; c++) {
8741                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8742                 *txdata_conv_28_conv = txdata_var.data[c];
8743                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
8744         }
8745         
8746         FREE(txdata_var.data);
8747         int32_t height_conv = height;
8748         js_invoke_function_uuuuuu(j_calls->instance_ptr, 54, (uint32_t)header_arr, (uint32_t)txdata_arr, height_conv, 0, 0, 0);
8749 }
8750 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
8751         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8752         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8753         memcpy(txid_arr->elems, *txid, 32);
8754         js_invoke_function_uuuuuu(j_calls->instance_ptr, 55, (uint32_t)txid_arr, 0, 0, 0, 0, 0);
8755 }
8756 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8757         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8758         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8759         memcpy(header_arr->elems, *header, 80);
8760         int32_t height_conv = height;
8761         js_invoke_function_uuuuuu(j_calls->instance_ptr, 56, (uint32_t)header_arr, height_conv, 0, 0, 0, 0);
8762 }
8763 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
8764         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8765         ptrArray ret = (ptrArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 57, 0, 0, 0, 0, 0, 0);
8766         LDKCVec_TxidZ ret_constr;
8767         ret_constr.datalen = ret->arr_len;
8768         if (ret_constr.datalen > 0)
8769                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8770         else
8771                 ret_constr.data = NULL;
8772         int8_tArray* ret_vals = (void*) ret->elems;
8773         for (size_t m = 0; m < ret_constr.datalen; m++) {
8774                 int8_tArray ret_conv_12 = ret_vals[m];
8775                 LDKThirtyTwoBytes ret_conv_12_ref;
8776                 CHECK(ret_conv_12->arr_len == 32);
8777                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
8778                 ret_constr.data[m] = ret_conv_12_ref;
8779         }
8780         FREE(ret);
8781         return ret_constr;
8782 }
8783 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
8784         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
8785         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8786 }
8787 static inline LDKConfirm LDKConfirm_init (JSValue o) {
8788         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
8789         atomic_init(&calls->refcnt, 1);
8790         calls->instance_ptr = o;
8791
8792         LDKConfirm ret = {
8793                 .this_arg = (void*) calls,
8794                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
8795                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
8796                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
8797                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
8798                 .free = LDKConfirm_JCalls_free,
8799         };
8800         return ret;
8801 }
8802 uint64_t  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
8803         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
8804         *res_ptr = LDKConfirm_init(o);
8805         return tag_ptr(res_ptr, true);
8806 }
8807 void  __attribute__((export_name("TS_Confirm_transactions_confirmed"))) TS_Confirm_transactions_confirmed(uint64_t this_arg, int8_tArray header, uint64_tArray txdata, int32_t height) {
8808         void* this_arg_ptr = untag_ptr(this_arg);
8809         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8810         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8811         unsigned char header_arr[80];
8812         CHECK(header->arr_len == 80);
8813         memcpy(header_arr, header->elems, 80); FREE(header);
8814         unsigned char (*header_ref)[80] = &header_arr;
8815         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8816         txdata_constr.datalen = txdata->arr_len;
8817         if (txdata_constr.datalen > 0)
8818                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8819         else
8820                 txdata_constr.data = NULL;
8821         uint64_t* txdata_vals = txdata->elems;
8822         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8823                 uint64_t txdata_conv_28 = txdata_vals[c];
8824                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
8825                 CHECK_ACCESS(txdata_conv_28_ptr);
8826                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8827                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
8828                 txdata_constr.data[c] = txdata_conv_28_conv;
8829         }
8830         FREE(txdata);
8831         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8832 }
8833
8834 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint64_t this_arg, int8_tArray txid) {
8835         void* this_arg_ptr = untag_ptr(this_arg);
8836         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8837         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8838         unsigned char txid_arr[32];
8839         CHECK(txid->arr_len == 32);
8840         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8841         unsigned char (*txid_ref)[32] = &txid_arr;
8842         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
8843 }
8844
8845 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint64_t this_arg, int8_tArray header, int32_t height) {
8846         void* this_arg_ptr = untag_ptr(this_arg);
8847         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8848         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8849         unsigned char header_arr[80];
8850         CHECK(header->arr_len == 80);
8851         memcpy(header_arr, header->elems, 80); FREE(header);
8852         unsigned char (*header_ref)[80] = &header_arr;
8853         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
8854 }
8855
8856 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint64_t this_arg) {
8857         void* this_arg_ptr = untag_ptr(this_arg);
8858         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8859         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8860         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8861         ptrArray ret_arr = NULL;
8862         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
8863         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
8864         for (size_t m = 0; m < ret_var.datalen; m++) {
8865                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
8866                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
8867                 ret_arr_ptr[m] = ret_conv_12_arr;
8868         }
8869         
8870         FREE(ret_var.data);
8871         return ret_arr;
8872 }
8873
8874 typedef struct LDKPersist_JCalls {
8875         atomic_size_t refcnt;
8876         uint32_t instance_ptr;
8877 } LDKPersist_JCalls;
8878 static void LDKPersist_JCalls_free(void* this_arg) {
8879         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8880         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8881                 FREE(j_calls);
8882         }
8883 }
8884 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8885         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8886         LDKOutPoint channel_id_var = channel_id;
8887         uint64_t channel_id_ref = 0;
8888         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8889         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
8890         LDKChannelMonitor data_var = *data;
8891         uint64_t data_ref = 0;
8892         data_var = ChannelMonitor_clone(&data_var);
8893         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8894         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
8895         LDKMonitorUpdateId update_id_var = update_id;
8896         uint64_t update_id_ref = 0;
8897         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8898         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
8899         uint64_t ret = js_invoke_function_bbbuuu(j_calls->instance_ptr, 58, channel_id_ref, data_ref, update_id_ref, 0, 0, 0);
8900         void* ret_ptr = untag_ptr(ret);
8901         CHECK_ACCESS(ret_ptr);
8902         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8903         FREE(untag_ptr(ret));
8904         return ret_conv;
8905 }
8906 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8907         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8908         LDKOutPoint channel_id_var = channel_id;
8909         uint64_t channel_id_ref = 0;
8910         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8911         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
8912         LDKChannelMonitorUpdate update_var = *update;
8913         uint64_t update_ref = 0;
8914         update_var = ChannelMonitorUpdate_clone(&update_var);
8915         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
8916         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
8917         LDKChannelMonitor data_var = *data;
8918         uint64_t data_ref = 0;
8919         data_var = ChannelMonitor_clone(&data_var);
8920         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8921         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
8922         LDKMonitorUpdateId update_id_var = update_id;
8923         uint64_t update_id_ref = 0;
8924         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8925         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
8926         uint64_t ret = js_invoke_function_bbbbuu(j_calls->instance_ptr, 59, channel_id_ref, update_ref, data_ref, update_id_ref, 0, 0);
8927         void* ret_ptr = untag_ptr(ret);
8928         CHECK_ACCESS(ret_ptr);
8929         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8930         FREE(untag_ptr(ret));
8931         return ret_conv;
8932 }
8933 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8934         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8935         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8936 }
8937 static inline LDKPersist LDKPersist_init (JSValue o) {
8938         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8939         atomic_init(&calls->refcnt, 1);
8940         calls->instance_ptr = o;
8941
8942         LDKPersist ret = {
8943                 .this_arg = (void*) calls,
8944                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
8945                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
8946                 .free = LDKPersist_JCalls_free,
8947         };
8948         return ret;
8949 }
8950 uint64_t  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
8951         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
8952         *res_ptr = LDKPersist_init(o);
8953         return tag_ptr(res_ptr, true);
8954 }
8955 uint64_t  __attribute__((export_name("TS_Persist_persist_new_channel"))) TS_Persist_persist_new_channel(uint64_t this_arg, uint64_t channel_id, uint64_t data, uint64_t update_id) {
8956         void* this_arg_ptr = untag_ptr(this_arg);
8957         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8958         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8959         LDKOutPoint channel_id_conv;
8960         channel_id_conv.inner = untag_ptr(channel_id);
8961         channel_id_conv.is_owned = ptr_is_owned(channel_id);
8962         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8963         channel_id_conv = OutPoint_clone(&channel_id_conv);
8964         LDKChannelMonitor data_conv;
8965         data_conv.inner = untag_ptr(data);
8966         data_conv.is_owned = ptr_is_owned(data);
8967         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8968         data_conv.is_owned = false;
8969         LDKMonitorUpdateId update_id_conv;
8970         update_id_conv.inner = untag_ptr(update_id);
8971         update_id_conv.is_owned = ptr_is_owned(update_id);
8972         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8973         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8974         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8975         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
8976         return tag_ptr(ret_conv, true);
8977 }
8978
8979 uint64_t  __attribute__((export_name("TS_Persist_update_persisted_channel"))) TS_Persist_update_persisted_channel(uint64_t this_arg, uint64_t channel_id, uint64_t update, uint64_t data, uint64_t update_id) {
8980         void* this_arg_ptr = untag_ptr(this_arg);
8981         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8982         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8983         LDKOutPoint channel_id_conv;
8984         channel_id_conv.inner = untag_ptr(channel_id);
8985         channel_id_conv.is_owned = ptr_is_owned(channel_id);
8986         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8987         channel_id_conv = OutPoint_clone(&channel_id_conv);
8988         LDKChannelMonitorUpdate update_conv;
8989         update_conv.inner = untag_ptr(update);
8990         update_conv.is_owned = ptr_is_owned(update);
8991         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
8992         update_conv.is_owned = false;
8993         LDKChannelMonitor data_conv;
8994         data_conv.inner = untag_ptr(data);
8995         data_conv.is_owned = ptr_is_owned(data);
8996         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8997         data_conv.is_owned = false;
8998         LDKMonitorUpdateId update_id_conv;
8999         update_id_conv.inner = untag_ptr(update_id);
9000         update_id_conv.is_owned = ptr_is_owned(update_id);
9001         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9002         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9003         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9004         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
9005         return tag_ptr(ret_conv, true);
9006 }
9007
9008 typedef struct LDKChannelMessageHandler_JCalls {
9009         atomic_size_t refcnt;
9010         uint32_t instance_ptr;
9011         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9012 } LDKChannelMessageHandler_JCalls;
9013 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
9014         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9015         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9016                 FREE(j_calls);
9017         }
9018 }
9019 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
9020         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9021         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9022         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9023         LDKInitFeatures their_features_var = their_features;
9024         uint64_t their_features_ref = 0;
9025         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9026         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
9027         LDKOpenChannel msg_var = *msg;
9028         uint64_t msg_ref = 0;
9029         msg_var = OpenChannel_clone(&msg_var);
9030         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9031         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9032         js_invoke_function_ubbuuu(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, their_features_ref, msg_ref, 0, 0, 0);
9033 }
9034 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
9035         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9036         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9037         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9038         LDKInitFeatures their_features_var = their_features;
9039         uint64_t their_features_ref = 0;
9040         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9041         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
9042         LDKAcceptChannel msg_var = *msg;
9043         uint64_t msg_ref = 0;
9044         msg_var = AcceptChannel_clone(&msg_var);
9045         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9046         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9047         js_invoke_function_ubbuuu(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, their_features_ref, msg_ref, 0, 0, 0);
9048 }
9049 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
9050         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9051         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9052         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9053         LDKFundingCreated msg_var = *msg;
9054         uint64_t msg_ref = 0;
9055         msg_var = FundingCreated_clone(&msg_var);
9056         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9057         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9058         js_invoke_function_ubuuuu(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9059 }
9060 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
9061         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9062         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9063         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9064         LDKFundingSigned msg_var = *msg;
9065         uint64_t msg_ref = 0;
9066         msg_var = FundingSigned_clone(&msg_var);
9067         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9068         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9069         js_invoke_function_ubuuuu(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9070 }
9071 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
9072         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9073         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9074         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9075         LDKChannelReady msg_var = *msg;
9076         uint64_t msg_ref = 0;
9077         msg_var = ChannelReady_clone(&msg_var);
9078         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9079         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9080         js_invoke_function_ubuuuu(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9081 }
9082 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
9083         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9084         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9085         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9086         LDKInitFeatures their_features_var = *their_features;
9087         uint64_t their_features_ref = 0;
9088         their_features_var = InitFeatures_clone(&their_features_var);
9089         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9090         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
9091         LDKShutdown msg_var = *msg;
9092         uint64_t msg_ref = 0;
9093         msg_var = Shutdown_clone(&msg_var);
9094         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9095         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9096         js_invoke_function_ubbuuu(j_calls->instance_ptr, 65, (uint32_t)their_node_id_arr, their_features_ref, msg_ref, 0, 0, 0);
9097 }
9098 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
9099         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9100         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9101         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9102         LDKClosingSigned msg_var = *msg;
9103         uint64_t msg_ref = 0;
9104         msg_var = ClosingSigned_clone(&msg_var);
9105         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9106         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9107         js_invoke_function_ubuuuu(j_calls->instance_ptr, 66, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9108 }
9109 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
9110         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9111         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9112         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9113         LDKUpdateAddHTLC msg_var = *msg;
9114         uint64_t msg_ref = 0;
9115         msg_var = UpdateAddHTLC_clone(&msg_var);
9116         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9117         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9118         js_invoke_function_ubuuuu(j_calls->instance_ptr, 67, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9119 }
9120 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
9121         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9122         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9123         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9124         LDKUpdateFulfillHTLC msg_var = *msg;
9125         uint64_t msg_ref = 0;
9126         msg_var = UpdateFulfillHTLC_clone(&msg_var);
9127         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9128         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9129         js_invoke_function_ubuuuu(j_calls->instance_ptr, 68, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9130 }
9131 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
9132         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9133         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9134         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9135         LDKUpdateFailHTLC msg_var = *msg;
9136         uint64_t msg_ref = 0;
9137         msg_var = UpdateFailHTLC_clone(&msg_var);
9138         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9139         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9140         js_invoke_function_ubuuuu(j_calls->instance_ptr, 69, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9141 }
9142 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
9143         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9144         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9145         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9146         LDKUpdateFailMalformedHTLC msg_var = *msg;
9147         uint64_t msg_ref = 0;
9148         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
9149         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9150         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9151         js_invoke_function_ubuuuu(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9152 }
9153 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
9154         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9155         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9156         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9157         LDKCommitmentSigned msg_var = *msg;
9158         uint64_t msg_ref = 0;
9159         msg_var = CommitmentSigned_clone(&msg_var);
9160         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9161         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9162         js_invoke_function_ubuuuu(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9163 }
9164 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
9165         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9166         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9167         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9168         LDKRevokeAndACK msg_var = *msg;
9169         uint64_t msg_ref = 0;
9170         msg_var = RevokeAndACK_clone(&msg_var);
9171         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9172         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9173         js_invoke_function_ubuuuu(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9174 }
9175 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
9176         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9177         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9178         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9179         LDKUpdateFee msg_var = *msg;
9180         uint64_t msg_ref = 0;
9181         msg_var = UpdateFee_clone(&msg_var);
9182         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9183         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9184         js_invoke_function_ubuuuu(j_calls->instance_ptr, 73, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9185 }
9186 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
9187         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9188         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9189         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9190         LDKAnnouncementSignatures msg_var = *msg;
9191         uint64_t msg_ref = 0;
9192         msg_var = AnnouncementSignatures_clone(&msg_var);
9193         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9194         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9195         js_invoke_function_ubuuuu(j_calls->instance_ptr, 74, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9196 }
9197 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
9198         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9199         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9200         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9201         jboolean no_connection_possible_conv = no_connection_possible;
9202         js_invoke_function_uuuuuu(j_calls->instance_ptr, 75, (uint32_t)their_node_id_arr, no_connection_possible_conv, 0, 0, 0, 0);
9203 }
9204 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
9205         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9206         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9207         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9208         LDKInit msg_var = *msg;
9209         uint64_t msg_ref = 0;
9210         msg_var = Init_clone(&msg_var);
9211         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9212         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9213         js_invoke_function_ubuuuu(j_calls->instance_ptr, 76, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9214 }
9215 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
9216         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9217         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9218         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9219         LDKChannelReestablish msg_var = *msg;
9220         uint64_t msg_ref = 0;
9221         msg_var = ChannelReestablish_clone(&msg_var);
9222         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9223         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9224         js_invoke_function_ubuuuu(j_calls->instance_ptr, 77, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9225 }
9226 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
9227         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9228         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9229         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9230         LDKChannelUpdate msg_var = *msg;
9231         uint64_t msg_ref = 0;
9232         msg_var = ChannelUpdate_clone(&msg_var);
9233         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9234         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9235         js_invoke_function_ubuuuu(j_calls->instance_ptr, 78, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9236 }
9237 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
9238         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9239         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9240         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9241         LDKErrorMessage msg_var = *msg;
9242         uint64_t msg_ref = 0;
9243         msg_var = ErrorMessage_clone(&msg_var);
9244         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9245         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9246         js_invoke_function_ubuuuu(j_calls->instance_ptr, 79, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9247 }
9248 LDKNodeFeatures provided_node_features_LDKChannelMessageHandler_jcall(const void* this_arg) {
9249         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9250         uint64_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 80, 0, 0, 0, 0, 0, 0);
9251         LDKNodeFeatures ret_conv;
9252         ret_conv.inner = untag_ptr(ret);
9253         ret_conv.is_owned = ptr_is_owned(ret);
9254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
9255         return ret_conv;
9256 }
9257 LDKInitFeatures provided_init_features_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
9258         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9259         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9260         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9261         uint64_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 81, (uint32_t)their_node_id_arr, 0, 0, 0, 0, 0);
9262         LDKInitFeatures ret_conv;
9263         ret_conv.inner = untag_ptr(ret);
9264         ret_conv.is_owned = ptr_is_owned(ret);
9265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
9266         return ret_conv;
9267 }
9268 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
9269         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
9270         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9271         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9272 }
9273 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9274         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
9275         atomic_init(&calls->refcnt, 1);
9276         calls->instance_ptr = o;
9277
9278         LDKChannelMessageHandler ret = {
9279                 .this_arg = (void*) calls,
9280                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
9281                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
9282                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
9283                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
9284                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
9285                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
9286                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
9287                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
9288                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
9289                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
9290                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
9291                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
9292                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
9293                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
9294                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
9295                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
9296                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
9297                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
9298                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
9299                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
9300                 .provided_node_features = provided_node_features_LDKChannelMessageHandler_jcall,
9301                 .provided_init_features = provided_init_features_LDKChannelMessageHandler_jcall,
9302                 .free = LDKChannelMessageHandler_JCalls_free,
9303                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9304         };
9305         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9306         return ret;
9307 }
9308 uint64_t  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9309         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
9310         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
9311         return tag_ptr(res_ptr, true);
9312 }
9313 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_open_channel"))) TS_ChannelMessageHandler_handle_open_channel(uint64_t this_arg, int8_tArray their_node_id, uint64_t their_features, uint64_t msg) {
9314         void* this_arg_ptr = untag_ptr(this_arg);
9315         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9316         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9317         LDKPublicKey their_node_id_ref;
9318         CHECK(their_node_id->arr_len == 33);
9319         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9320         LDKInitFeatures their_features_conv;
9321         their_features_conv.inner = untag_ptr(their_features);
9322         their_features_conv.is_owned = ptr_is_owned(their_features);
9323         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9324         their_features_conv = InitFeatures_clone(&their_features_conv);
9325         LDKOpenChannel msg_conv;
9326         msg_conv.inner = untag_ptr(msg);
9327         msg_conv.is_owned = ptr_is_owned(msg);
9328         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9329         msg_conv.is_owned = false;
9330         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9331 }
9332
9333 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_accept_channel"))) TS_ChannelMessageHandler_handle_accept_channel(uint64_t this_arg, int8_tArray their_node_id, uint64_t their_features, uint64_t msg) {
9334         void* this_arg_ptr = untag_ptr(this_arg);
9335         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9336         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9337         LDKPublicKey their_node_id_ref;
9338         CHECK(their_node_id->arr_len == 33);
9339         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9340         LDKInitFeatures their_features_conv;
9341         their_features_conv.inner = untag_ptr(their_features);
9342         their_features_conv.is_owned = ptr_is_owned(their_features);
9343         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9344         their_features_conv = InitFeatures_clone(&their_features_conv);
9345         LDKAcceptChannel msg_conv;
9346         msg_conv.inner = untag_ptr(msg);
9347         msg_conv.is_owned = ptr_is_owned(msg);
9348         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9349         msg_conv.is_owned = false;
9350         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9351 }
9352
9353 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_funding_created"))) TS_ChannelMessageHandler_handle_funding_created(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9354         void* this_arg_ptr = untag_ptr(this_arg);
9355         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9356         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9357         LDKPublicKey their_node_id_ref;
9358         CHECK(their_node_id->arr_len == 33);
9359         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9360         LDKFundingCreated msg_conv;
9361         msg_conv.inner = untag_ptr(msg);
9362         msg_conv.is_owned = ptr_is_owned(msg);
9363         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9364         msg_conv.is_owned = false;
9365         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9366 }
9367
9368 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_funding_signed"))) TS_ChannelMessageHandler_handle_funding_signed(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9369         void* this_arg_ptr = untag_ptr(this_arg);
9370         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9371         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9372         LDKPublicKey their_node_id_ref;
9373         CHECK(their_node_id->arr_len == 33);
9374         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9375         LDKFundingSigned msg_conv;
9376         msg_conv.inner = untag_ptr(msg);
9377         msg_conv.is_owned = ptr_is_owned(msg);
9378         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9379         msg_conv.is_owned = false;
9380         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9381 }
9382
9383 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_channel_ready"))) TS_ChannelMessageHandler_handle_channel_ready(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9384         void* this_arg_ptr = untag_ptr(this_arg);
9385         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9386         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9387         LDKPublicKey their_node_id_ref;
9388         CHECK(their_node_id->arr_len == 33);
9389         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9390         LDKChannelReady msg_conv;
9391         msg_conv.inner = untag_ptr(msg);
9392         msg_conv.is_owned = ptr_is_owned(msg);
9393         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9394         msg_conv.is_owned = false;
9395         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9396 }
9397
9398 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_shutdown"))) TS_ChannelMessageHandler_handle_shutdown(uint64_t this_arg, int8_tArray their_node_id, uint64_t their_features, uint64_t msg) {
9399         void* this_arg_ptr = untag_ptr(this_arg);
9400         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9401         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9402         LDKPublicKey their_node_id_ref;
9403         CHECK(their_node_id->arr_len == 33);
9404         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9405         LDKInitFeatures their_features_conv;
9406         their_features_conv.inner = untag_ptr(their_features);
9407         their_features_conv.is_owned = ptr_is_owned(their_features);
9408         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9409         their_features_conv.is_owned = false;
9410         LDKShutdown msg_conv;
9411         msg_conv.inner = untag_ptr(msg);
9412         msg_conv.is_owned = ptr_is_owned(msg);
9413         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9414         msg_conv.is_owned = false;
9415         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9416 }
9417
9418 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_closing_signed"))) TS_ChannelMessageHandler_handle_closing_signed(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9419         void* this_arg_ptr = untag_ptr(this_arg);
9420         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9421         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9422         LDKPublicKey their_node_id_ref;
9423         CHECK(their_node_id->arr_len == 33);
9424         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9425         LDKClosingSigned msg_conv;
9426         msg_conv.inner = untag_ptr(msg);
9427         msg_conv.is_owned = ptr_is_owned(msg);
9428         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9429         msg_conv.is_owned = false;
9430         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9431 }
9432
9433 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_update_add_htlc"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9434         void* this_arg_ptr = untag_ptr(this_arg);
9435         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9436         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9437         LDKPublicKey their_node_id_ref;
9438         CHECK(their_node_id->arr_len == 33);
9439         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9440         LDKUpdateAddHTLC msg_conv;
9441         msg_conv.inner = untag_ptr(msg);
9442         msg_conv.is_owned = ptr_is_owned(msg);
9443         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9444         msg_conv.is_owned = false;
9445         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9446 }
9447
9448 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_update_fulfill_htlc"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9449         void* this_arg_ptr = untag_ptr(this_arg);
9450         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9451         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9452         LDKPublicKey their_node_id_ref;
9453         CHECK(their_node_id->arr_len == 33);
9454         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9455         LDKUpdateFulfillHTLC msg_conv;
9456         msg_conv.inner = untag_ptr(msg);
9457         msg_conv.is_owned = ptr_is_owned(msg);
9458         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9459         msg_conv.is_owned = false;
9460         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9461 }
9462
9463 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_update_fail_htlc"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9464         void* this_arg_ptr = untag_ptr(this_arg);
9465         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9466         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9467         LDKPublicKey their_node_id_ref;
9468         CHECK(their_node_id->arr_len == 33);
9469         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9470         LDKUpdateFailHTLC msg_conv;
9471         msg_conv.inner = untag_ptr(msg);
9472         msg_conv.is_owned = ptr_is_owned(msg);
9473         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9474         msg_conv.is_owned = false;
9475         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9476 }
9477
9478 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_update_fail_malformed_htlc"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9479         void* this_arg_ptr = untag_ptr(this_arg);
9480         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9481         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9482         LDKPublicKey their_node_id_ref;
9483         CHECK(their_node_id->arr_len == 33);
9484         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9485         LDKUpdateFailMalformedHTLC msg_conv;
9486         msg_conv.inner = untag_ptr(msg);
9487         msg_conv.is_owned = ptr_is_owned(msg);
9488         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9489         msg_conv.is_owned = false;
9490         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9491 }
9492
9493 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_commitment_signed"))) TS_ChannelMessageHandler_handle_commitment_signed(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9494         void* this_arg_ptr = untag_ptr(this_arg);
9495         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9496         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9497         LDKPublicKey their_node_id_ref;
9498         CHECK(their_node_id->arr_len == 33);
9499         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9500         LDKCommitmentSigned msg_conv;
9501         msg_conv.inner = untag_ptr(msg);
9502         msg_conv.is_owned = ptr_is_owned(msg);
9503         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9504         msg_conv.is_owned = false;
9505         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9506 }
9507
9508 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_revoke_and_ack"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9509         void* this_arg_ptr = untag_ptr(this_arg);
9510         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9511         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9512         LDKPublicKey their_node_id_ref;
9513         CHECK(their_node_id->arr_len == 33);
9514         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9515         LDKRevokeAndACK msg_conv;
9516         msg_conv.inner = untag_ptr(msg);
9517         msg_conv.is_owned = ptr_is_owned(msg);
9518         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9519         msg_conv.is_owned = false;
9520         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9521 }
9522
9523 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_update_fee"))) TS_ChannelMessageHandler_handle_update_fee(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9524         void* this_arg_ptr = untag_ptr(this_arg);
9525         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9526         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9527         LDKPublicKey their_node_id_ref;
9528         CHECK(their_node_id->arr_len == 33);
9529         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9530         LDKUpdateFee msg_conv;
9531         msg_conv.inner = untag_ptr(msg);
9532         msg_conv.is_owned = ptr_is_owned(msg);
9533         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9534         msg_conv.is_owned = false;
9535         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9536 }
9537
9538 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_announcement_signatures"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9539         void* this_arg_ptr = untag_ptr(this_arg);
9540         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9541         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9542         LDKPublicKey their_node_id_ref;
9543         CHECK(their_node_id->arr_len == 33);
9544         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9545         LDKAnnouncementSignatures msg_conv;
9546         msg_conv.inner = untag_ptr(msg);
9547         msg_conv.is_owned = ptr_is_owned(msg);
9548         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9549         msg_conv.is_owned = false;
9550         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9551 }
9552
9553 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_disconnected"))) TS_ChannelMessageHandler_peer_disconnected(uint64_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
9554         void* this_arg_ptr = untag_ptr(this_arg);
9555         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9556         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9557         LDKPublicKey their_node_id_ref;
9558         CHECK(their_node_id->arr_len == 33);
9559         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9560         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9561 }
9562
9563 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9564         void* this_arg_ptr = untag_ptr(this_arg);
9565         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9566         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9567         LDKPublicKey their_node_id_ref;
9568         CHECK(their_node_id->arr_len == 33);
9569         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9570         LDKInit msg_conv;
9571         msg_conv.inner = untag_ptr(msg);
9572         msg_conv.is_owned = ptr_is_owned(msg);
9573         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9574         msg_conv.is_owned = false;
9575         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9576 }
9577
9578 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_channel_reestablish"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9579         void* this_arg_ptr = untag_ptr(this_arg);
9580         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9581         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9582         LDKPublicKey their_node_id_ref;
9583         CHECK(their_node_id->arr_len == 33);
9584         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9585         LDKChannelReestablish msg_conv;
9586         msg_conv.inner = untag_ptr(msg);
9587         msg_conv.is_owned = ptr_is_owned(msg);
9588         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9589         msg_conv.is_owned = false;
9590         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9591 }
9592
9593 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_channel_update"))) TS_ChannelMessageHandler_handle_channel_update(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9594         void* this_arg_ptr = untag_ptr(this_arg);
9595         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9596         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9597         LDKPublicKey their_node_id_ref;
9598         CHECK(their_node_id->arr_len == 33);
9599         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9600         LDKChannelUpdate msg_conv;
9601         msg_conv.inner = untag_ptr(msg);
9602         msg_conv.is_owned = ptr_is_owned(msg);
9603         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9604         msg_conv.is_owned = false;
9605         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9606 }
9607
9608 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9609         void* this_arg_ptr = untag_ptr(this_arg);
9610         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9611         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9612         LDKPublicKey their_node_id_ref;
9613         CHECK(their_node_id->arr_len == 33);
9614         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9615         LDKErrorMessage msg_conv;
9616         msg_conv.inner = untag_ptr(msg);
9617         msg_conv.is_owned = ptr_is_owned(msg);
9618         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9619         msg_conv.is_owned = false;
9620         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9621 }
9622
9623 uint64_t  __attribute__((export_name("TS_ChannelMessageHandler_provided_node_features"))) TS_ChannelMessageHandler_provided_node_features(uint64_t this_arg) {
9624         void* this_arg_ptr = untag_ptr(this_arg);
9625         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9626         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9627         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
9628         uint64_t ret_ref = 0;
9629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9630         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9631         return ret_ref;
9632 }
9633
9634 uint64_t  __attribute__((export_name("TS_ChannelMessageHandler_provided_init_features"))) TS_ChannelMessageHandler_provided_init_features(uint64_t this_arg, int8_tArray their_node_id) {
9635         void* this_arg_ptr = untag_ptr(this_arg);
9636         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9637         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9638         LDKPublicKey their_node_id_ref;
9639         CHECK(their_node_id->arr_len == 33);
9640         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9641         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
9642         uint64_t ret_ref = 0;
9643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9644         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9645         return ret_ref;
9646 }
9647
9648 typedef struct LDKRoutingMessageHandler_JCalls {
9649         atomic_size_t refcnt;
9650         uint32_t instance_ptr;
9651         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9652 } LDKRoutingMessageHandler_JCalls;
9653 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9654         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9655         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9656                 FREE(j_calls);
9657         }
9658 }
9659 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9660         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9661         LDKNodeAnnouncement msg_var = *msg;
9662         uint64_t msg_ref = 0;
9663         msg_var = NodeAnnouncement_clone(&msg_var);
9664         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9665         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9666         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 82, msg_ref, 0, 0, 0, 0, 0);
9667         void* ret_ptr = untag_ptr(ret);
9668         CHECK_ACCESS(ret_ptr);
9669         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9670         FREE(untag_ptr(ret));
9671         return ret_conv;
9672 }
9673 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9674         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9675         LDKChannelAnnouncement msg_var = *msg;
9676         uint64_t msg_ref = 0;
9677         msg_var = ChannelAnnouncement_clone(&msg_var);
9678         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9679         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9680         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 83, msg_ref, 0, 0, 0, 0, 0);
9681         void* ret_ptr = untag_ptr(ret);
9682         CHECK_ACCESS(ret_ptr);
9683         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9684         FREE(untag_ptr(ret));
9685         return ret_conv;
9686 }
9687 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9688         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9689         LDKChannelUpdate msg_var = *msg;
9690         uint64_t msg_ref = 0;
9691         msg_var = ChannelUpdate_clone(&msg_var);
9692         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9693         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9694         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 84, msg_ref, 0, 0, 0, 0, 0);
9695         void* ret_ptr = untag_ptr(ret);
9696         CHECK_ACCESS(ret_ptr);
9697         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9698         FREE(untag_ptr(ret));
9699         return ret_conv;
9700 }
9701 LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point) {
9702         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9703         int64_t starting_point_conv = starting_point;
9704         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 85, starting_point_conv, 0, 0, 0, 0, 0);
9705         void* ret_ptr = untag_ptr(ret);
9706         CHECK_ACCESS(ret_ptr);
9707         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(ret_ptr);
9708         FREE(untag_ptr(ret));
9709         return ret_conv;
9710 }
9711 LDKNodeAnnouncement get_next_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point) {
9712         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9713         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
9714         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
9715         uint64_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 86, (uint32_t)starting_point_arr, 0, 0, 0, 0, 0);
9716         LDKNodeAnnouncement ret_conv;
9717         ret_conv.inner = untag_ptr(ret);
9718         ret_conv.is_owned = ptr_is_owned(ret);
9719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
9720         return ret_conv;
9721 }
9722 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9723         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9724         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9725         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9726         LDKInit init_var = *init;
9727         uint64_t init_ref = 0;
9728         init_var = Init_clone(&init_var);
9729         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
9730         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
9731         js_invoke_function_ubuuuu(j_calls->instance_ptr, 87, (uint32_t)their_node_id_arr, init_ref, 0, 0, 0, 0);
9732 }
9733 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9734         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9735         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9736         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9737         LDKReplyChannelRange msg_var = msg;
9738         uint64_t msg_ref = 0;
9739         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9740         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9741         uint64_t ret = js_invoke_function_ubuuuu(j_calls->instance_ptr, 88, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9742         void* ret_ptr = untag_ptr(ret);
9743         CHECK_ACCESS(ret_ptr);
9744         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9745         FREE(untag_ptr(ret));
9746         return ret_conv;
9747 }
9748 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9749         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9750         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9751         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9752         LDKReplyShortChannelIdsEnd msg_var = msg;
9753         uint64_t msg_ref = 0;
9754         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9755         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9756         uint64_t ret = js_invoke_function_ubuuuu(j_calls->instance_ptr, 89, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9757         void* ret_ptr = untag_ptr(ret);
9758         CHECK_ACCESS(ret_ptr);
9759         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9760         FREE(untag_ptr(ret));
9761         return ret_conv;
9762 }
9763 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9764         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9765         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9766         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9767         LDKQueryChannelRange msg_var = msg;
9768         uint64_t msg_ref = 0;
9769         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9770         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9771         uint64_t ret = js_invoke_function_ubuuuu(j_calls->instance_ptr, 90, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9772         void* ret_ptr = untag_ptr(ret);
9773         CHECK_ACCESS(ret_ptr);
9774         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9775         FREE(untag_ptr(ret));
9776         return ret_conv;
9777 }
9778 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9779         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9780         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9781         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9782         LDKQueryShortChannelIds msg_var = msg;
9783         uint64_t msg_ref = 0;
9784         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9785         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
9786         uint64_t ret = js_invoke_function_ubuuuu(j_calls->instance_ptr, 91, (uint32_t)their_node_id_arr, msg_ref, 0, 0, 0, 0);
9787         void* ret_ptr = untag_ptr(ret);
9788         CHECK_ACCESS(ret_ptr);
9789         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9790         FREE(untag_ptr(ret));
9791         return ret_conv;
9792 }
9793 LDKNodeFeatures provided_node_features_LDKRoutingMessageHandler_jcall(const void* this_arg) {
9794         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9795         uint64_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 92, 0, 0, 0, 0, 0, 0);
9796         LDKNodeFeatures ret_conv;
9797         ret_conv.inner = untag_ptr(ret);
9798         ret_conv.is_owned = ptr_is_owned(ret);
9799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
9800         return ret_conv;
9801 }
9802 LDKInitFeatures provided_init_features_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
9803         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9804         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9805         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9806         uint64_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 93, (uint32_t)their_node_id_arr, 0, 0, 0, 0, 0);
9807         LDKInitFeatures ret_conv;
9808         ret_conv.inner = untag_ptr(ret);
9809         ret_conv.is_owned = ptr_is_owned(ret);
9810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
9811         return ret_conv;
9812 }
9813 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9814         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9815         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9816         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9817 }
9818 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9819         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9820         atomic_init(&calls->refcnt, 1);
9821         calls->instance_ptr = o;
9822
9823         LDKRoutingMessageHandler ret = {
9824                 .this_arg = (void*) calls,
9825                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9826                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9827                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9828                 .get_next_channel_announcement = get_next_channel_announcement_LDKRoutingMessageHandler_jcall,
9829                 .get_next_node_announcement = get_next_node_announcement_LDKRoutingMessageHandler_jcall,
9830                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
9831                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9832                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9833                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9834                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9835                 .provided_node_features = provided_node_features_LDKRoutingMessageHandler_jcall,
9836                 .provided_init_features = provided_init_features_LDKRoutingMessageHandler_jcall,
9837                 .free = LDKRoutingMessageHandler_JCalls_free,
9838                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9839         };
9840         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9841         return ret;
9842 }
9843 uint64_t  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9844         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9845         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
9846         return tag_ptr(res_ptr, true);
9847 }
9848 uint64_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint64_t this_arg, uint64_t msg) {
9849         void* this_arg_ptr = untag_ptr(this_arg);
9850         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9851         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9852         LDKNodeAnnouncement msg_conv;
9853         msg_conv.inner = untag_ptr(msg);
9854         msg_conv.is_owned = ptr_is_owned(msg);
9855         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9856         msg_conv.is_owned = false;
9857         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9858         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9859         return tag_ptr(ret_conv, true);
9860 }
9861
9862 uint64_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint64_t this_arg, uint64_t msg) {
9863         void* this_arg_ptr = untag_ptr(this_arg);
9864         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9865         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9866         LDKChannelAnnouncement msg_conv;
9867         msg_conv.inner = untag_ptr(msg);
9868         msg_conv.is_owned = ptr_is_owned(msg);
9869         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9870         msg_conv.is_owned = false;
9871         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9872         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
9873         return tag_ptr(ret_conv, true);
9874 }
9875
9876 uint64_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint64_t this_arg, uint64_t msg) {
9877         void* this_arg_ptr = untag_ptr(this_arg);
9878         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9879         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9880         LDKChannelUpdate msg_conv;
9881         msg_conv.inner = untag_ptr(msg);
9882         msg_conv.is_owned = ptr_is_owned(msg);
9883         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9884         msg_conv.is_owned = false;
9885         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9886         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
9887         return tag_ptr(ret_conv, true);
9888 }
9889
9890 uint64_t  __attribute__((export_name("TS_RoutingMessageHandler_get_next_channel_announcement"))) TS_RoutingMessageHandler_get_next_channel_announcement(uint64_t this_arg, int64_t starting_point) {
9891         void* this_arg_ptr = untag_ptr(this_arg);
9892         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9893         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9894         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
9895         *ret_copy = (this_arg_conv->get_next_channel_announcement)(this_arg_conv->this_arg, starting_point);
9896         uint64_t ret_ref = tag_ptr(ret_copy, true);
9897         return ret_ref;
9898 }
9899
9900 uint64_t  __attribute__((export_name("TS_RoutingMessageHandler_get_next_node_announcement"))) TS_RoutingMessageHandler_get_next_node_announcement(uint64_t this_arg, int8_tArray starting_point) {
9901         void* this_arg_ptr = untag_ptr(this_arg);
9902         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9903         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9904         LDKPublicKey starting_point_ref;
9905         CHECK(starting_point->arr_len == 33);
9906         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
9907         LDKNodeAnnouncement ret_var = (this_arg_conv->get_next_node_announcement)(this_arg_conv->this_arg, starting_point_ref);
9908         uint64_t ret_ref = 0;
9909         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9910         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9911         return ret_ref;
9912 }
9913
9914 void  __attribute__((export_name("TS_RoutingMessageHandler_peer_connected"))) TS_RoutingMessageHandler_peer_connected(uint64_t this_arg, int8_tArray their_node_id, uint64_t init) {
9915         void* this_arg_ptr = untag_ptr(this_arg);
9916         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9917         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9918         LDKPublicKey their_node_id_ref;
9919         CHECK(their_node_id->arr_len == 33);
9920         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9921         LDKInit init_conv;
9922         init_conv.inner = untag_ptr(init);
9923         init_conv.is_owned = ptr_is_owned(init);
9924         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
9925         init_conv.is_owned = false;
9926         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
9927 }
9928
9929 uint64_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_reply_channel_range"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9930         void* this_arg_ptr = untag_ptr(this_arg);
9931         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9932         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9933         LDKPublicKey their_node_id_ref;
9934         CHECK(their_node_id->arr_len == 33);
9935         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9936         LDKReplyChannelRange msg_conv;
9937         msg_conv.inner = untag_ptr(msg);
9938         msg_conv.is_owned = ptr_is_owned(msg);
9939         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9940         msg_conv = ReplyChannelRange_clone(&msg_conv);
9941         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9942         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9943         return tag_ptr(ret_conv, true);
9944 }
9945
9946 uint64_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_reply_short_channel_ids_end"))) TS_RoutingMessageHandler_handle_reply_short_channel_ids_end(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9947         void* this_arg_ptr = untag_ptr(this_arg);
9948         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9949         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9950         LDKPublicKey their_node_id_ref;
9951         CHECK(their_node_id->arr_len == 33);
9952         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9953         LDKReplyShortChannelIdsEnd msg_conv;
9954         msg_conv.inner = untag_ptr(msg);
9955         msg_conv.is_owned = ptr_is_owned(msg);
9956         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9957         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
9958         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9959         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9960         return tag_ptr(ret_conv, true);
9961 }
9962
9963 uint64_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_query_channel_range"))) TS_RoutingMessageHandler_handle_query_channel_range(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9964         void* this_arg_ptr = untag_ptr(this_arg);
9965         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9966         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9967         LDKPublicKey their_node_id_ref;
9968         CHECK(their_node_id->arr_len == 33);
9969         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9970         LDKQueryChannelRange msg_conv;
9971         msg_conv.inner = untag_ptr(msg);
9972         msg_conv.is_owned = ptr_is_owned(msg);
9973         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9974         msg_conv = QueryChannelRange_clone(&msg_conv);
9975         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9976         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9977         return tag_ptr(ret_conv, true);
9978 }
9979
9980 uint64_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_query_short_channel_ids"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint64_t this_arg, int8_tArray their_node_id, uint64_t msg) {
9981         void* this_arg_ptr = untag_ptr(this_arg);
9982         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9983         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9984         LDKPublicKey their_node_id_ref;
9985         CHECK(their_node_id->arr_len == 33);
9986         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9987         LDKQueryShortChannelIds msg_conv;
9988         msg_conv.inner = untag_ptr(msg);
9989         msg_conv.is_owned = ptr_is_owned(msg);
9990         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9991         msg_conv = QueryShortChannelIds_clone(&msg_conv);
9992         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9993         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9994         return tag_ptr(ret_conv, true);
9995 }
9996
9997 uint64_t  __attribute__((export_name("TS_RoutingMessageHandler_provided_node_features"))) TS_RoutingMessageHandler_provided_node_features(uint64_t this_arg) {
9998         void* this_arg_ptr = untag_ptr(this_arg);
9999         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10000         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10001         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
10002         uint64_t ret_ref = 0;
10003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10004         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10005         return ret_ref;
10006 }
10007
10008 uint64_t  __attribute__((export_name("TS_RoutingMessageHandler_provided_init_features"))) TS_RoutingMessageHandler_provided_init_features(uint64_t this_arg, int8_tArray their_node_id) {
10009         void* this_arg_ptr = untag_ptr(this_arg);
10010         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10011         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10012         LDKPublicKey their_node_id_ref;
10013         CHECK(their_node_id->arr_len == 33);
10014         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10015         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
10016         uint64_t ret_ref = 0;
10017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10019         return ret_ref;
10020 }
10021
10022 typedef struct LDKOnionMessageHandler_JCalls {
10023         atomic_size_t refcnt;
10024         uint32_t instance_ptr;
10025         LDKOnionMessageProvider_JCalls* OnionMessageProvider;
10026 } LDKOnionMessageHandler_JCalls;
10027 static void LDKOnionMessageHandler_JCalls_free(void* this_arg) {
10028         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
10029         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10030                 FREE(j_calls);
10031         }
10032 }
10033 void handle_onion_message_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey peer_node_id, const LDKOnionMessage * msg) {
10034         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
10035         int8_tArray peer_node_id_arr = init_int8_tArray(33, __LINE__);
10036         memcpy(peer_node_id_arr->elems, peer_node_id.compressed_form, 33);
10037         LDKOnionMessage msg_var = *msg;
10038         uint64_t msg_ref = 0;
10039         msg_var = OnionMessage_clone(&msg_var);
10040         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10041         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
10042         js_invoke_function_ubuuuu(j_calls->instance_ptr, 94, (uint32_t)peer_node_id_arr, msg_ref, 0, 0, 0, 0);
10043 }
10044 void peer_connected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
10045         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
10046         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10047         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10048         LDKInit init_var = *init;
10049         uint64_t init_ref = 0;
10050         init_var = Init_clone(&init_var);
10051         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
10052         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
10053         js_invoke_function_ubuuuu(j_calls->instance_ptr, 95, (uint32_t)their_node_id_arr, init_ref, 0, 0, 0, 0);
10054 }
10055 void peer_disconnected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
10056         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
10057         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10058         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10059         jboolean no_connection_possible_conv = no_connection_possible;
10060         js_invoke_function_uuuuuu(j_calls->instance_ptr, 96, (uint32_t)their_node_id_arr, no_connection_possible_conv, 0, 0, 0, 0);
10061 }
10062 LDKNodeFeatures provided_node_features_LDKOnionMessageHandler_jcall(const void* this_arg) {
10063         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
10064         uint64_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 97, 0, 0, 0, 0, 0, 0);
10065         LDKNodeFeatures ret_conv;
10066         ret_conv.inner = untag_ptr(ret);
10067         ret_conv.is_owned = ptr_is_owned(ret);
10068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
10069         return ret_conv;
10070 }
10071 LDKInitFeatures provided_init_features_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
10072         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
10073         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10074         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10075         uint64_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 98, (uint32_t)their_node_id_arr, 0, 0, 0, 0, 0);
10076         LDKInitFeatures ret_conv;
10077         ret_conv.inner = untag_ptr(ret);
10078         ret_conv.is_owned = ptr_is_owned(ret);
10079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
10080         return ret_conv;
10081 }
10082 static void LDKOnionMessageHandler_JCalls_cloned(LDKOnionMessageHandler* new_obj) {
10083         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) new_obj->this_arg;
10084         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10085         atomic_fetch_add_explicit(&j_calls->OnionMessageProvider->refcnt, 1, memory_order_release);
10086 }
10087 static inline LDKOnionMessageHandler LDKOnionMessageHandler_init (JSValue o, JSValue OnionMessageProvider) {
10088         LDKOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKOnionMessageHandler_JCalls), "LDKOnionMessageHandler_JCalls");
10089         atomic_init(&calls->refcnt, 1);
10090         calls->instance_ptr = o;
10091
10092         LDKOnionMessageHandler ret = {
10093                 .this_arg = (void*) calls,
10094                 .handle_onion_message = handle_onion_message_LDKOnionMessageHandler_jcall,
10095                 .peer_connected = peer_connected_LDKOnionMessageHandler_jcall,
10096                 .peer_disconnected = peer_disconnected_LDKOnionMessageHandler_jcall,
10097                 .provided_node_features = provided_node_features_LDKOnionMessageHandler_jcall,
10098                 .provided_init_features = provided_init_features_LDKOnionMessageHandler_jcall,
10099                 .free = LDKOnionMessageHandler_JCalls_free,
10100                 .OnionMessageProvider = LDKOnionMessageProvider_init(OnionMessageProvider),
10101         };
10102         calls->OnionMessageProvider = ret.OnionMessageProvider.this_arg;
10103         return ret;
10104 }
10105 uint64_t  __attribute__((export_name("TS_LDKOnionMessageHandler_new"))) TS_LDKOnionMessageHandler_new(JSValue o, JSValue OnionMessageProvider) {
10106         LDKOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
10107         *res_ptr = LDKOnionMessageHandler_init(o, OnionMessageProvider);
10108         return tag_ptr(res_ptr, true);
10109 }
10110 void  __attribute__((export_name("TS_OnionMessageHandler_handle_onion_message"))) TS_OnionMessageHandler_handle_onion_message(uint64_t this_arg, int8_tArray peer_node_id, uint64_t msg) {
10111         void* this_arg_ptr = untag_ptr(this_arg);
10112         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10113         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
10114         LDKPublicKey peer_node_id_ref;
10115         CHECK(peer_node_id->arr_len == 33);
10116         memcpy(peer_node_id_ref.compressed_form, peer_node_id->elems, 33); FREE(peer_node_id);
10117         LDKOnionMessage msg_conv;
10118         msg_conv.inner = untag_ptr(msg);
10119         msg_conv.is_owned = ptr_is_owned(msg);
10120         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10121         msg_conv.is_owned = false;
10122         (this_arg_conv->handle_onion_message)(this_arg_conv->this_arg, peer_node_id_ref, &msg_conv);
10123 }
10124
10125 void  __attribute__((export_name("TS_OnionMessageHandler_peer_connected"))) TS_OnionMessageHandler_peer_connected(uint64_t this_arg, int8_tArray their_node_id, uint64_t init) {
10126         void* this_arg_ptr = untag_ptr(this_arg);
10127         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10128         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
10129         LDKPublicKey their_node_id_ref;
10130         CHECK(their_node_id->arr_len == 33);
10131         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10132         LDKInit init_conv;
10133         init_conv.inner = untag_ptr(init);
10134         init_conv.is_owned = ptr_is_owned(init);
10135         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
10136         init_conv.is_owned = false;
10137         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
10138 }
10139
10140 void  __attribute__((export_name("TS_OnionMessageHandler_peer_disconnected"))) TS_OnionMessageHandler_peer_disconnected(uint64_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
10141         void* this_arg_ptr = untag_ptr(this_arg);
10142         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10143         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
10144         LDKPublicKey their_node_id_ref;
10145         CHECK(their_node_id->arr_len == 33);
10146         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10147         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
10148 }
10149
10150 uint64_t  __attribute__((export_name("TS_OnionMessageHandler_provided_node_features"))) TS_OnionMessageHandler_provided_node_features(uint64_t this_arg) {
10151         void* this_arg_ptr = untag_ptr(this_arg);
10152         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10153         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
10154         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
10155         uint64_t ret_ref = 0;
10156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10157         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10158         return ret_ref;
10159 }
10160
10161 uint64_t  __attribute__((export_name("TS_OnionMessageHandler_provided_init_features"))) TS_OnionMessageHandler_provided_init_features(uint64_t this_arg, int8_tArray their_node_id) {
10162         void* this_arg_ptr = untag_ptr(this_arg);
10163         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10164         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
10165         LDKPublicKey their_node_id_ref;
10166         CHECK(their_node_id->arr_len == 33);
10167         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10168         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
10169         uint64_t ret_ref = 0;
10170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10171         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10172         return ret_ref;
10173 }
10174
10175 typedef struct LDKCustomMessageReader_JCalls {
10176         atomic_size_t refcnt;
10177         uint32_t instance_ptr;
10178 } LDKCustomMessageReader_JCalls;
10179 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
10180         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10181         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10182                 FREE(j_calls);
10183         }
10184 }
10185 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
10186         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10187         int16_t message_type_conv = message_type;
10188         LDKu8slice buffer_var = buffer;
10189         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
10190         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
10191         uint64_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 99, message_type_conv, (uint32_t)buffer_arr, 0, 0, 0, 0);
10192         void* ret_ptr = untag_ptr(ret);
10193         CHECK_ACCESS(ret_ptr);
10194         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
10195         FREE(untag_ptr(ret));
10196         return ret_conv;
10197 }
10198 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
10199         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
10200         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10201 }
10202 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
10203         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
10204         atomic_init(&calls->refcnt, 1);
10205         calls->instance_ptr = o;
10206
10207         LDKCustomMessageReader ret = {
10208                 .this_arg = (void*) calls,
10209                 .read = read_LDKCustomMessageReader_jcall,
10210                 .free = LDKCustomMessageReader_JCalls_free,
10211         };
10212         return ret;
10213 }
10214 uint64_t  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
10215         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
10216         *res_ptr = LDKCustomMessageReader_init(o);
10217         return tag_ptr(res_ptr, true);
10218 }
10219 uint64_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint64_t this_arg, int16_t message_type, int8_tArray buffer) {
10220         void* this_arg_ptr = untag_ptr(this_arg);
10221         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10222         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
10223         LDKu8slice buffer_ref;
10224         buffer_ref.datalen = buffer->arr_len;
10225         buffer_ref.data = buffer->elems;
10226         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10227         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
10228         FREE(buffer);
10229         return tag_ptr(ret_conv, true);
10230 }
10231
10232 typedef struct LDKCustomMessageHandler_JCalls {
10233         atomic_size_t refcnt;
10234         uint32_t instance_ptr;
10235         LDKCustomMessageReader_JCalls* CustomMessageReader;
10236 } LDKCustomMessageHandler_JCalls;
10237 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
10238         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10239         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10240                 FREE(j_calls);
10241         }
10242 }
10243 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
10244         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10245         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
10246         *msg_ret = msg;
10247         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
10248         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
10249         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 100, tag_ptr(msg_ret, true), (uint32_t)sender_node_id_arr, 0, 0, 0, 0);
10250         void* ret_ptr = untag_ptr(ret);
10251         CHECK_ACCESS(ret_ptr);
10252         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10253         FREE(untag_ptr(ret));
10254         return ret_conv;
10255 }
10256 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
10257         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10258         uint64_tArray ret = (uint64_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 101, 0, 0, 0, 0, 0, 0);
10259         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
10260         ret_constr.datalen = ret->arr_len;
10261         if (ret_constr.datalen > 0)
10262                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
10263         else
10264                 ret_constr.data = NULL;
10265         uint64_t* ret_vals = ret->elems;
10266         for (size_t z = 0; z < ret_constr.datalen; z++) {
10267                 uint64_t ret_conv_25 = ret_vals[z];
10268                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
10269                 CHECK_ACCESS(ret_conv_25_ptr);
10270                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
10271                 FREE(untag_ptr(ret_conv_25));
10272                 ret_constr.data[z] = ret_conv_25_conv;
10273         }
10274         FREE(ret);
10275         return ret_constr;
10276 }
10277 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
10278         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
10279         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10280         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
10281 }
10282 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
10283         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
10284         atomic_init(&calls->refcnt, 1);
10285         calls->instance_ptr = o;
10286
10287         LDKCustomMessageHandler ret = {
10288                 .this_arg = (void*) calls,
10289                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
10290                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
10291                 .free = LDKCustomMessageHandler_JCalls_free,
10292                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
10293         };
10294         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
10295         return ret;
10296 }
10297 uint64_t  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
10298         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
10299         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
10300         return tag_ptr(res_ptr, true);
10301 }
10302 uint64_t  __attribute__((export_name("TS_CustomMessageHandler_handle_custom_message"))) TS_CustomMessageHandler_handle_custom_message(uint64_t this_arg, uint64_t msg, int8_tArray sender_node_id) {
10303         void* this_arg_ptr = untag_ptr(this_arg);
10304         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10305         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10306         void* msg_ptr = untag_ptr(msg);
10307         CHECK_ACCESS(msg_ptr);
10308         LDKType msg_conv = *(LDKType*)(msg_ptr);
10309         if (msg_conv.free == LDKType_JCalls_free) {
10310                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10311                 LDKType_JCalls_cloned(&msg_conv);
10312         }
10313         LDKPublicKey sender_node_id_ref;
10314         CHECK(sender_node_id->arr_len == 33);
10315         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
10316         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10317         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
10318         return tag_ptr(ret_conv, true);
10319 }
10320
10321 uint64_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint64_t this_arg) {
10322         void* this_arg_ptr = untag_ptr(this_arg);
10323         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10324         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10325         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
10326         uint64_tArray ret_arr = NULL;
10327         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
10328         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
10329         for (size_t z = 0; z < ret_var.datalen; z++) {
10330                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10331                 *ret_conv_25_conv = ret_var.data[z];
10332                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
10333         }
10334         
10335         FREE(ret_var.data);
10336         return ret_arr;
10337 }
10338
10339 typedef struct LDKSocketDescriptor_JCalls {
10340         atomic_size_t refcnt;
10341         uint32_t instance_ptr;
10342 } LDKSocketDescriptor_JCalls;
10343 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
10344         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10345         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10346                 FREE(j_calls);
10347         }
10348 }
10349 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
10350         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10351         LDKu8slice data_var = data;
10352         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
10353         memcpy(data_arr->elems, data_var.data, data_var.datalen);
10354         jboolean resume_read_conv = resume_read;
10355         return js_invoke_function_uuuuuu(j_calls->instance_ptr, 102, (uint32_t)data_arr, resume_read_conv, 0, 0, 0, 0);
10356 }
10357 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
10358         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10359         js_invoke_function_uuuuuu(j_calls->instance_ptr, 103, 0, 0, 0, 0, 0, 0);
10360 }
10361 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
10362         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10363         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10364         *other_arg_clone = SocketDescriptor_clone(other_arg);
10365         return js_invoke_function_buuuuu(j_calls->instance_ptr, 104, tag_ptr(other_arg_clone, true), 0, 0, 0, 0, 0);
10366 }
10367 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
10368         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10369         return js_invoke_function_uuuuuu(j_calls->instance_ptr, 105, 0, 0, 0, 0, 0, 0);
10370 }
10371 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
10372         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
10373         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10374 }
10375 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
10376         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
10377         atomic_init(&calls->refcnt, 1);
10378         calls->instance_ptr = o;
10379
10380         LDKSocketDescriptor ret = {
10381                 .this_arg = (void*) calls,
10382                 .send_data = send_data_LDKSocketDescriptor_jcall,
10383                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
10384                 .eq = eq_LDKSocketDescriptor_jcall,
10385                 .hash = hash_LDKSocketDescriptor_jcall,
10386                 .cloned = LDKSocketDescriptor_JCalls_cloned,
10387                 .free = LDKSocketDescriptor_JCalls_free,
10388         };
10389         return ret;
10390 }
10391 uint64_t  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
10392         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10393         *res_ptr = LDKSocketDescriptor_init(o);
10394         return tag_ptr(res_ptr, true);
10395 }
10396 uint32_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint64_t this_arg, int8_tArray data, jboolean resume_read) {
10397         void* this_arg_ptr = untag_ptr(this_arg);
10398         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10399         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10400         LDKu8slice data_ref;
10401         data_ref.datalen = data->arr_len;
10402         data_ref.data = data->elems;
10403         uint32_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
10404         FREE(data);
10405         return ret_conv;
10406 }
10407
10408 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint64_t this_arg) {
10409         void* this_arg_ptr = untag_ptr(this_arg);
10410         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10411         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10412         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
10413 }
10414
10415 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint64_t this_arg) {
10416         void* this_arg_ptr = untag_ptr(this_arg);
10417         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10418         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10419         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
10420         return ret_conv;
10421 }
10422
10423 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_ty_from_ptr"))) TS_LDKEffectiveCapacity_ty_from_ptr(uint64_t ptr) {
10424         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
10425         switch(obj->tag) {
10426                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
10427                 case LDKEffectiveCapacity_MaximumHTLC: return 1;
10428                 case LDKEffectiveCapacity_Total: return 2;
10429                 case LDKEffectiveCapacity_Infinite: return 3;
10430                 case LDKEffectiveCapacity_Unknown: return 4;
10431                 default: abort();
10432         }
10433 }
10434 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat"))) TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(uint64_t ptr) {
10435         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
10436         assert(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
10437                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
10438         return liquidity_msat_conv;
10439 }
10440 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat"))) TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(uint64_t ptr) {
10441         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
10442         assert(obj->tag == LDKEffectiveCapacity_MaximumHTLC);
10443                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
10444         return amount_msat_conv;
10445 }
10446 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_capacity_msat"))) TS_LDKEffectiveCapacity_Total_get_capacity_msat(uint64_t ptr) {
10447         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
10448         assert(obj->tag == LDKEffectiveCapacity_Total);
10449                         int64_t capacity_msat_conv = obj->total.capacity_msat;
10450         return capacity_msat_conv;
10451 }
10452 uint64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_htlc_maximum_msat"))) TS_LDKEffectiveCapacity_Total_get_htlc_maximum_msat(uint64_t ptr) {
10453         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
10454         assert(obj->tag == LDKEffectiveCapacity_Total);
10455                         uint64_t htlc_maximum_msat_ref = tag_ptr(&obj->total.htlc_maximum_msat, false);
10456         return htlc_maximum_msat_ref;
10457 }
10458 uint32_t __attribute__((export_name("TS_LDKDestination_ty_from_ptr"))) TS_LDKDestination_ty_from_ptr(uint64_t ptr) {
10459         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
10460         switch(obj->tag) {
10461                 case LDKDestination_Node: return 0;
10462                 case LDKDestination_BlindedRoute: return 1;
10463                 default: abort();
10464         }
10465 }
10466 int8_tArray __attribute__((export_name("TS_LDKDestination_Node_get_node"))) TS_LDKDestination_Node_get_node(uint64_t ptr) {
10467         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
10468         assert(obj->tag == LDKDestination_Node);
10469                         int8_tArray node_arr = init_int8_tArray(33, __LINE__);
10470                         memcpy(node_arr->elems, obj->node.compressed_form, 33);
10471         return node_arr;
10472 }
10473 uint64_t __attribute__((export_name("TS_LDKDestination_BlindedRoute_get_blinded_route"))) TS_LDKDestination_BlindedRoute_get_blinded_route(uint64_t ptr) {
10474         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
10475         assert(obj->tag == LDKDestination_BlindedRoute);
10476                         LDKBlindedRoute blinded_route_var = obj->blinded_route;
10477                         uint64_t blinded_route_ref = 0;
10478                         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_route_var);
10479                         blinded_route_ref = tag_ptr(blinded_route_var.inner, false);
10480         return blinded_route_ref;
10481 }
10482 uint32_t __attribute__((export_name("TS_LDKFallback_ty_from_ptr"))) TS_LDKFallback_ty_from_ptr(uint64_t ptr) {
10483         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
10484         switch(obj->tag) {
10485                 case LDKFallback_SegWitProgram: return 0;
10486                 case LDKFallback_PubKeyHash: return 1;
10487                 case LDKFallback_ScriptHash: return 2;
10488                 default: abort();
10489         }
10490 }
10491 int8_t __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_version"))) TS_LDKFallback_SegWitProgram_get_version(uint64_t ptr) {
10492         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
10493         assert(obj->tag == LDKFallback_SegWitProgram);
10494                         uint8_t version_val = obj->seg_wit_program.version._0;
10495         return version_val;
10496 }
10497 int8_tArray __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_program"))) TS_LDKFallback_SegWitProgram_get_program(uint64_t ptr) {
10498         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
10499         assert(obj->tag == LDKFallback_SegWitProgram);
10500                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10501                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
10502                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
10503         return program_arr;
10504 }
10505 int8_tArray __attribute__((export_name("TS_LDKFallback_PubKeyHash_get_pub_key_hash"))) TS_LDKFallback_PubKeyHash_get_pub_key_hash(uint64_t ptr) {
10506         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
10507         assert(obj->tag == LDKFallback_PubKeyHash);
10508                         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
10509                         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
10510         return pub_key_hash_arr;
10511 }
10512 int8_tArray __attribute__((export_name("TS_LDKFallback_ScriptHash_get_script_hash"))) TS_LDKFallback_ScriptHash_get_script_hash(uint64_t ptr) {
10513         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
10514         assert(obj->tag == LDKFallback_ScriptHash);
10515                         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
10516                         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
10517         return script_hash_arr;
10518 }
10519 typedef struct LDKPayer_JCalls {
10520         atomic_size_t refcnt;
10521         uint32_t instance_ptr;
10522 } LDKPayer_JCalls;
10523 static void LDKPayer_JCalls_free(void* this_arg) {
10524         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10525         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10526                 FREE(j_calls);
10527         }
10528 }
10529 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10530         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10531         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 106, 0, 0, 0, 0, 0, 0);
10532         LDKPublicKey ret_ref;
10533         CHECK(ret->arr_len == 33);
10534         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
10535         return ret_ref;
10536 }
10537 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10538         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10539         uint64_tArray ret = (uint64_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 107, 0, 0, 0, 0, 0, 0);
10540         LDKCVec_ChannelDetailsZ ret_constr;
10541         ret_constr.datalen = ret->arr_len;
10542         if (ret_constr.datalen > 0)
10543                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10544         else
10545                 ret_constr.data = NULL;
10546         uint64_t* ret_vals = ret->elems;
10547         for (size_t q = 0; q < ret_constr.datalen; q++) {
10548                 uint64_t ret_conv_16 = ret_vals[q];
10549                 LDKChannelDetails ret_conv_16_conv;
10550                 ret_conv_16_conv.inner = untag_ptr(ret_conv_16);
10551                 ret_conv_16_conv.is_owned = ptr_is_owned(ret_conv_16);
10552                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10553                 ret_constr.data[q] = ret_conv_16_conv;
10554         }
10555         FREE(ret);
10556         return ret_constr;
10557 }
10558 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10559         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10560         LDKRoute route_var = *route;
10561         uint64_t route_ref = 0;
10562         route_var = Route_clone(&route_var);
10563         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10564         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
10565         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10566         memcpy(payment_hash_arr->elems, payment_hash.data, 32);
10567         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
10568         memcpy(payment_secret_arr->elems, payment_secret.data, 32);
10569         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 108, route_ref, (uint32_t)payment_hash_arr, (uint32_t)payment_secret_arr, 0, 0, 0);
10570         void* ret_ptr = untag_ptr(ret);
10571         CHECK_ACCESS(ret_ptr);
10572         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10573         FREE(untag_ptr(ret));
10574         return ret_conv;
10575 }
10576 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
10577         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10578         LDKRoute route_var = *route;
10579         uint64_t route_ref = 0;
10580         route_var = Route_clone(&route_var);
10581         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10582         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
10583         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10584         memcpy(payment_preimage_arr->elems, payment_preimage.data, 32);
10585         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 109, route_ref, (uint32_t)payment_preimage_arr, 0, 0, 0, 0);
10586         void* ret_ptr = untag_ptr(ret);
10587         CHECK_ACCESS(ret_ptr);
10588         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10589         FREE(untag_ptr(ret));
10590         return ret_conv;
10591 }
10592 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
10593         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10594         LDKRoute route_var = *route;
10595         uint64_t route_ref = 0;
10596         route_var = Route_clone(&route_var);
10597         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10598         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
10599         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10600         memcpy(payment_id_arr->elems, payment_id.data, 32);
10601         uint64_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 110, route_ref, (uint32_t)payment_id_arr, 0, 0, 0, 0);
10602         void* ret_ptr = untag_ptr(ret);
10603         CHECK_ACCESS(ret_ptr);
10604         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
10605         FREE(untag_ptr(ret));
10606         return ret_conv;
10607 }
10608 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
10609         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10610         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10611         memcpy(payment_id_arr->elems, payment_id.data, 32);
10612         js_invoke_function_uuuuuu(j_calls->instance_ptr, 111, (uint32_t)payment_id_arr, 0, 0, 0, 0, 0);
10613 }
10614 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
10615         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
10616         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10617 }
10618 static inline LDKPayer LDKPayer_init (JSValue o) {
10619         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
10620         atomic_init(&calls->refcnt, 1);
10621         calls->instance_ptr = o;
10622
10623         LDKPayer ret = {
10624                 .this_arg = (void*) calls,
10625                 .node_id = node_id_LDKPayer_jcall,
10626                 .first_hops = first_hops_LDKPayer_jcall,
10627                 .send_payment = send_payment_LDKPayer_jcall,
10628                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
10629                 .retry_payment = retry_payment_LDKPayer_jcall,
10630                 .abandon_payment = abandon_payment_LDKPayer_jcall,
10631                 .free = LDKPayer_JCalls_free,
10632         };
10633         return ret;
10634 }
10635 uint64_t  __attribute__((export_name("TS_LDKPayer_new"))) TS_LDKPayer_new(JSValue o) {
10636         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
10637         *res_ptr = LDKPayer_init(o);
10638         return tag_ptr(res_ptr, true);
10639 }
10640 int8_tArray  __attribute__((export_name("TS_Payer_node_id"))) TS_Payer_node_id(uint64_t this_arg) {
10641         void* this_arg_ptr = untag_ptr(this_arg);
10642         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10643         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10644         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
10645         memcpy(ret_arr->elems, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
10646         return ret_arr;
10647 }
10648
10649 uint64_tArray  __attribute__((export_name("TS_Payer_first_hops"))) TS_Payer_first_hops(uint64_t this_arg) {
10650         void* this_arg_ptr = untag_ptr(this_arg);
10651         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10652         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10653         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
10654         uint64_tArray ret_arr = NULL;
10655         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
10656         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
10657         for (size_t q = 0; q < ret_var.datalen; q++) {
10658                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10659                 uint64_t ret_conv_16_ref = 0;
10660                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
10661                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
10662                 ret_arr_ptr[q] = ret_conv_16_ref;
10663         }
10664         
10665         FREE(ret_var.data);
10666         return ret_arr;
10667 }
10668
10669 uint64_t  __attribute__((export_name("TS_Payer_send_payment"))) TS_Payer_send_payment(uint64_t this_arg, uint64_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
10670         void* this_arg_ptr = untag_ptr(this_arg);
10671         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10672         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10673         LDKRoute route_conv;
10674         route_conv.inner = untag_ptr(route);
10675         route_conv.is_owned = ptr_is_owned(route);
10676         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10677         route_conv.is_owned = false;
10678         LDKThirtyTwoBytes payment_hash_ref;
10679         CHECK(payment_hash->arr_len == 32);
10680         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
10681         LDKThirtyTwoBytes payment_secret_ref;
10682         CHECK(payment_secret->arr_len == 32);
10683         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
10684         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10685         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
10686         return tag_ptr(ret_conv, true);
10687 }
10688
10689 uint64_t  __attribute__((export_name("TS_Payer_send_spontaneous_payment"))) TS_Payer_send_spontaneous_payment(uint64_t this_arg, uint64_t route, int8_tArray payment_preimage) {
10690         void* this_arg_ptr = untag_ptr(this_arg);
10691         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10692         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10693         LDKRoute route_conv;
10694         route_conv.inner = untag_ptr(route);
10695         route_conv.is_owned = ptr_is_owned(route);
10696         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10697         route_conv.is_owned = false;
10698         LDKThirtyTwoBytes payment_preimage_ref;
10699         CHECK(payment_preimage->arr_len == 32);
10700         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
10701         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10702         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
10703         return tag_ptr(ret_conv, true);
10704 }
10705
10706 uint64_t  __attribute__((export_name("TS_Payer_retry_payment"))) TS_Payer_retry_payment(uint64_t this_arg, uint64_t route, int8_tArray payment_id) {
10707         void* this_arg_ptr = untag_ptr(this_arg);
10708         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10709         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10710         LDKRoute route_conv;
10711         route_conv.inner = untag_ptr(route);
10712         route_conv.is_owned = ptr_is_owned(route);
10713         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10714         route_conv.is_owned = false;
10715         LDKThirtyTwoBytes payment_id_ref;
10716         CHECK(payment_id->arr_len == 32);
10717         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10718         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10719         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
10720         return tag_ptr(ret_conv, true);
10721 }
10722
10723 void  __attribute__((export_name("TS_Payer_abandon_payment"))) TS_Payer_abandon_payment(uint64_t this_arg, int8_tArray payment_id) {
10724         void* this_arg_ptr = untag_ptr(this_arg);
10725         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10726         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10727         LDKThirtyTwoBytes payment_id_ref;
10728         CHECK(payment_id->arr_len == 32);
10729         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10730         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
10731 }
10732
10733 typedef struct LDKRouter_JCalls {
10734         atomic_size_t refcnt;
10735         uint32_t instance_ptr;
10736 } LDKRouter_JCalls;
10737 static void LDKRouter_JCalls_free(void* this_arg) {
10738         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10739         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10740                 FREE(j_calls);
10741         }
10742 }
10743 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, const uint8_t (* payment_hash)[32], LDKCVec_ChannelDetailsZ * first_hops, LDKInFlightHtlcs inflight_htlcs) {
10744         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10745         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
10746         memcpy(payer_arr->elems, payer.compressed_form, 33);
10747         LDKRouteParameters route_params_var = *route_params;
10748         uint64_t route_params_ref = 0;
10749         route_params_var = RouteParameters_clone(&route_params_var);
10750         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
10751         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
10752         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10753         memcpy(payment_hash_arr->elems, *payment_hash, 32);
10754         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
10755         uint64_tArray first_hops_arr = NULL;
10756         if (first_hops != NULL) {
10757                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
10758                 first_hops_arr = init_uint64_tArray(first_hops_var.datalen, __LINE__);
10759                 uint64_t *first_hops_arr_ptr = (uint64_t*)(((uint8_t*)first_hops_arr) + 8);
10760                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
10761                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
10762                         uint64_t first_hops_conv_16_ref = 0;
10763                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
10764                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
10765                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
10766                 }
10767         
10768         }
10769         LDKInFlightHtlcs inflight_htlcs_var = inflight_htlcs;
10770         uint64_t inflight_htlcs_ref = 0;
10771         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
10772         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
10773         uint64_t ret = js_invoke_function_ubuubu(j_calls->instance_ptr, 112, (uint32_t)payer_arr, route_params_ref, (uint32_t)payment_hash_arr, (uint32_t)first_hops_arr, inflight_htlcs_ref, 0);
10774         void* ret_ptr = untag_ptr(ret);
10775         CHECK_ACCESS(ret_ptr);
10776         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
10777         FREE(untag_ptr(ret));
10778         return ret_conv;
10779 }
10780 void notify_payment_path_failed_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10781         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10782         LDKCVec_RouteHopZ path_var = path;
10783         uint64_tArray path_arr = NULL;
10784         path_arr = init_uint64_tArray(path_var.datalen, __LINE__);
10785         uint64_t *path_arr_ptr = (uint64_t*)(((uint8_t*)path_arr) + 8);
10786         for (size_t k = 0; k < path_var.datalen; k++) {
10787                 LDKRouteHop path_conv_10_var = path_var.data[k];
10788                 uint64_t path_conv_10_ref = 0;
10789                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10790                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
10791                 path_arr_ptr[k] = path_conv_10_ref;
10792         }
10793         
10794         FREE(path_var.data);
10795         int64_t short_channel_id_conv = short_channel_id;
10796         js_invoke_function_ubuuuu(j_calls->instance_ptr, 113, (uint32_t)path_arr, short_channel_id_conv, 0, 0, 0, 0);
10797 }
10798 void notify_payment_path_successful_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path) {
10799         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10800         LDKCVec_RouteHopZ path_var = path;
10801         uint64_tArray path_arr = NULL;
10802         path_arr = init_uint64_tArray(path_var.datalen, __LINE__);
10803         uint64_t *path_arr_ptr = (uint64_t*)(((uint8_t*)path_arr) + 8);
10804         for (size_t k = 0; k < path_var.datalen; k++) {
10805                 LDKRouteHop path_conv_10_var = path_var.data[k];
10806                 uint64_t path_conv_10_ref = 0;
10807                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10808                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
10809                 path_arr_ptr[k] = path_conv_10_ref;
10810         }
10811         
10812         FREE(path_var.data);
10813         js_invoke_function_uuuuuu(j_calls->instance_ptr, 114, (uint32_t)path_arr, 0, 0, 0, 0, 0);
10814 }
10815 void notify_payment_probe_successful_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path) {
10816         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10817         LDKCVec_RouteHopZ path_var = path;
10818         uint64_tArray path_arr = NULL;
10819         path_arr = init_uint64_tArray(path_var.datalen, __LINE__);
10820         uint64_t *path_arr_ptr = (uint64_t*)(((uint8_t*)path_arr) + 8);
10821         for (size_t k = 0; k < path_var.datalen; k++) {
10822                 LDKRouteHop path_conv_10_var = path_var.data[k];
10823                 uint64_t path_conv_10_ref = 0;
10824                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10825                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
10826                 path_arr_ptr[k] = path_conv_10_ref;
10827         }
10828         
10829         FREE(path_var.data);
10830         js_invoke_function_uuuuuu(j_calls->instance_ptr, 115, (uint32_t)path_arr, 0, 0, 0, 0, 0);
10831 }
10832 void notify_payment_probe_failed_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10833         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10834         LDKCVec_RouteHopZ path_var = path;
10835         uint64_tArray path_arr = NULL;
10836         path_arr = init_uint64_tArray(path_var.datalen, __LINE__);
10837         uint64_t *path_arr_ptr = (uint64_t*)(((uint8_t*)path_arr) + 8);
10838         for (size_t k = 0; k < path_var.datalen; k++) {
10839                 LDKRouteHop path_conv_10_var = path_var.data[k];
10840                 uint64_t path_conv_10_ref = 0;
10841                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10842                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
10843                 path_arr_ptr[k] = path_conv_10_ref;
10844         }
10845         
10846         FREE(path_var.data);
10847         int64_t short_channel_id_conv = short_channel_id;
10848         js_invoke_function_ubuuuu(j_calls->instance_ptr, 116, (uint32_t)path_arr, short_channel_id_conv, 0, 0, 0, 0);
10849 }
10850 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
10851         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
10852         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10853 }
10854 static inline LDKRouter LDKRouter_init (JSValue o) {
10855         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
10856         atomic_init(&calls->refcnt, 1);
10857         calls->instance_ptr = o;
10858
10859         LDKRouter ret = {
10860                 .this_arg = (void*) calls,
10861                 .find_route = find_route_LDKRouter_jcall,
10862                 .notify_payment_path_failed = notify_payment_path_failed_LDKRouter_jcall,
10863                 .notify_payment_path_successful = notify_payment_path_successful_LDKRouter_jcall,
10864                 .notify_payment_probe_successful = notify_payment_probe_successful_LDKRouter_jcall,
10865                 .notify_payment_probe_failed = notify_payment_probe_failed_LDKRouter_jcall,
10866                 .free = LDKRouter_JCalls_free,
10867         };
10868         return ret;
10869 }
10870 uint64_t  __attribute__((export_name("TS_LDKRouter_new"))) TS_LDKRouter_new(JSValue o) {
10871         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
10872         *res_ptr = LDKRouter_init(o);
10873         return tag_ptr(res_ptr, true);
10874 }
10875 uint64_t  __attribute__((export_name("TS_Router_find_route"))) TS_Router_find_route(uint64_t this_arg, int8_tArray payer, uint64_t route_params, int8_tArray payment_hash, uint64_tArray first_hops, uint64_t inflight_htlcs) {
10876         void* this_arg_ptr = untag_ptr(this_arg);
10877         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10878         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10879         LDKPublicKey payer_ref;
10880         CHECK(payer->arr_len == 33);
10881         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
10882         LDKRouteParameters route_params_conv;
10883         route_params_conv.inner = untag_ptr(route_params);
10884         route_params_conv.is_owned = ptr_is_owned(route_params);
10885         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
10886         route_params_conv.is_owned = false;
10887         unsigned char payment_hash_arr[32];
10888         CHECK(payment_hash->arr_len == 32);
10889         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
10890         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
10891         LDKCVec_ChannelDetailsZ first_hops_constr;
10892         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
10893         if (first_hops != 0) {
10894                 first_hops_constr.datalen = first_hops->arr_len;
10895                 if (first_hops_constr.datalen > 0)
10896                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10897                 else
10898                         first_hops_constr.data = NULL;
10899                 uint64_t* first_hops_vals = first_hops->elems;
10900                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
10901                         uint64_t first_hops_conv_16 = first_hops_vals[q];
10902                         LDKChannelDetails first_hops_conv_16_conv;
10903                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
10904                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
10905                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
10906                         first_hops_conv_16_conv.is_owned = false;
10907                         first_hops_constr.data[q] = first_hops_conv_16_conv;
10908                 }
10909                 FREE(first_hops);
10910                 first_hops_ptr = &first_hops_constr;
10911         }
10912         LDKInFlightHtlcs inflight_htlcs_conv;
10913         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
10914         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
10915         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
10916         // WARNING: we need a move here but no clone is available for LDKInFlightHtlcs
10917         
10918         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10919         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, payment_hash_ref, first_hops_ptr, inflight_htlcs_conv);
10920         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
10921         return tag_ptr(ret_conv, true);
10922 }
10923
10924 void  __attribute__((export_name("TS_Router_notify_payment_path_failed"))) TS_Router_notify_payment_path_failed(uint64_t this_arg, uint64_tArray path, int64_t short_channel_id) {
10925         void* this_arg_ptr = untag_ptr(this_arg);
10926         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10927         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10928         LDKCVec_RouteHopZ path_constr;
10929         path_constr.datalen = path->arr_len;
10930         if (path_constr.datalen > 0)
10931                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10932         else
10933                 path_constr.data = NULL;
10934         uint64_t* path_vals = path->elems;
10935         for (size_t k = 0; k < path_constr.datalen; k++) {
10936                 uint64_t path_conv_10 = path_vals[k];
10937                 LDKRouteHop path_conv_10_conv;
10938                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
10939                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
10940                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10941                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10942                 path_constr.data[k] = path_conv_10_conv;
10943         }
10944         FREE(path);
10945         (this_arg_conv->notify_payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10946 }
10947
10948 void  __attribute__((export_name("TS_Router_notify_payment_path_successful"))) TS_Router_notify_payment_path_successful(uint64_t this_arg, uint64_tArray path) {
10949         void* this_arg_ptr = untag_ptr(this_arg);
10950         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10951         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10952         LDKCVec_RouteHopZ path_constr;
10953         path_constr.datalen = path->arr_len;
10954         if (path_constr.datalen > 0)
10955                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10956         else
10957                 path_constr.data = NULL;
10958         uint64_t* path_vals = path->elems;
10959         for (size_t k = 0; k < path_constr.datalen; k++) {
10960                 uint64_t path_conv_10 = path_vals[k];
10961                 LDKRouteHop path_conv_10_conv;
10962                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
10963                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
10964                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10965                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10966                 path_constr.data[k] = path_conv_10_conv;
10967         }
10968         FREE(path);
10969         (this_arg_conv->notify_payment_path_successful)(this_arg_conv->this_arg, path_constr);
10970 }
10971
10972 void  __attribute__((export_name("TS_Router_notify_payment_probe_successful"))) TS_Router_notify_payment_probe_successful(uint64_t this_arg, uint64_tArray path) {
10973         void* this_arg_ptr = untag_ptr(this_arg);
10974         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10975         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10976         LDKCVec_RouteHopZ path_constr;
10977         path_constr.datalen = path->arr_len;
10978         if (path_constr.datalen > 0)
10979                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10980         else
10981                 path_constr.data = NULL;
10982         uint64_t* path_vals = path->elems;
10983         for (size_t k = 0; k < path_constr.datalen; k++) {
10984                 uint64_t path_conv_10 = path_vals[k];
10985                 LDKRouteHop path_conv_10_conv;
10986                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
10987                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
10988                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10989                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10990                 path_constr.data[k] = path_conv_10_conv;
10991         }
10992         FREE(path);
10993         (this_arg_conv->notify_payment_probe_successful)(this_arg_conv->this_arg, path_constr);
10994 }
10995
10996 void  __attribute__((export_name("TS_Router_notify_payment_probe_failed"))) TS_Router_notify_payment_probe_failed(uint64_t this_arg, uint64_tArray path, int64_t short_channel_id) {
10997         void* this_arg_ptr = untag_ptr(this_arg);
10998         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10999         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
11000         LDKCVec_RouteHopZ path_constr;
11001         path_constr.datalen = path->arr_len;
11002         if (path_constr.datalen > 0)
11003                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11004         else
11005                 path_constr.data = NULL;
11006         uint64_t* path_vals = path->elems;
11007         for (size_t k = 0; k < path_constr.datalen; k++) {
11008                 uint64_t path_conv_10 = path_vals[k];
11009                 LDKRouteHop path_conv_10_conv;
11010                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
11011                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
11012                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
11013                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
11014                 path_constr.data[k] = path_conv_10_conv;
11015         }
11016         FREE(path);
11017         (this_arg_conv->notify_payment_probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
11018 }
11019
11020 uint32_t __attribute__((export_name("TS_LDKRetry_ty_from_ptr"))) TS_LDKRetry_ty_from_ptr(uint64_t ptr) {
11021         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
11022         switch(obj->tag) {
11023                 case LDKRetry_Attempts: return 0;
11024                 default: abort();
11025         }
11026 }
11027 uint32_t __attribute__((export_name("TS_LDKRetry_Attempts_get_attempts"))) TS_LDKRetry_Attempts_get_attempts(uint64_t ptr) {
11028         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
11029         assert(obj->tag == LDKRetry_Attempts);
11030                         uint32_t attempts_conv = obj->attempts;
11031         return attempts_conv;
11032 }
11033 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
11034         LDKStr ret_str = _ldk_get_compiled_version();
11035         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
11036         Str_free(ret_str);
11037         return ret_conv;
11038 }
11039
11040 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
11041         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
11042         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
11043         Str_free(ret_str);
11044         return ret_conv;
11045 }
11046
11047 uint64_t  __attribute__((export_name("TS_BigEndianScalar_new"))) TS_BigEndianScalar_new(int8_tArray big_endian_bytes) {
11048         LDKThirtyTwoBytes big_endian_bytes_ref;
11049         CHECK(big_endian_bytes->arr_len == 32);
11050         memcpy(big_endian_bytes_ref.data, big_endian_bytes->elems, 32); FREE(big_endian_bytes);
11051         LDKBigEndianScalar* ret_ref = MALLOC(sizeof(LDKBigEndianScalar), "LDKBigEndianScalar");
11052         *ret_ref = BigEndianScalar_new(big_endian_bytes_ref);
11053         return tag_ptr(ret_ref, true);
11054 }
11055
11056 static inline uint64_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
11057         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
11058         *ret_copy = Bech32Error_clone(arg);
11059         uint64_t ret_ref = tag_ptr(ret_copy, true);
11060         return ret_ref;
11061 }
11062 int64_t  __attribute__((export_name("TS_Bech32Error_clone_ptr"))) TS_Bech32Error_clone_ptr(uint64_t arg) {
11063         LDKBech32Error* arg_conv = (LDKBech32Error*)untag_ptr(arg);
11064         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
11065         return ret_conv;
11066 }
11067
11068 uint64_t  __attribute__((export_name("TS_Bech32Error_clone"))) TS_Bech32Error_clone(uint64_t orig) {
11069         LDKBech32Error* orig_conv = (LDKBech32Error*)untag_ptr(orig);
11070         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
11071         *ret_copy = Bech32Error_clone(orig_conv);
11072         uint64_t ret_ref = tag_ptr(ret_copy, true);
11073         return ret_ref;
11074 }
11075
11076 void  __attribute__((export_name("TS_Bech32Error_free"))) TS_Bech32Error_free(uint64_t o) {
11077         if (!ptr_is_owned(o)) return;
11078         void* o_ptr = untag_ptr(o);
11079         CHECK_ACCESS(o_ptr);
11080         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
11081         FREE(untag_ptr(o));
11082         Bech32Error_free(o_conv);
11083 }
11084
11085 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
11086         LDKTransaction _res_ref;
11087         _res_ref.datalen = _res->arr_len;
11088         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
11089         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
11090         _res_ref.data_is_owned = true;
11091         Transaction_free(_res_ref);
11092 }
11093
11094 uint64_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
11095         LDKCVec_u8Z script_pubkey_ref;
11096         script_pubkey_ref.datalen = script_pubkey->arr_len;
11097         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
11098         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
11099         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11100         *ret_ref = TxOut_new(script_pubkey_ref, value);
11101         return tag_ptr(ret_ref, true);
11102 }
11103
11104 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint64_t _res) {
11105         if (!ptr_is_owned(_res)) return;
11106         void* _res_ptr = untag_ptr(_res);
11107         CHECK_ACCESS(_res_ptr);
11108         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
11109         FREE(untag_ptr(_res));
11110         TxOut_free(_res_conv);
11111 }
11112
11113 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
11114         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11115         *ret_ref = TxOut_clone(arg);
11116         return tag_ptr(ret_ref, true);
11117 }
11118 int64_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint64_t arg) {
11119         LDKTxOut* arg_conv = (LDKTxOut*)untag_ptr(arg);
11120         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
11121         return ret_conv;
11122 }
11123
11124 uint64_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint64_t orig) {
11125         LDKTxOut* orig_conv = (LDKTxOut*)untag_ptr(orig);
11126         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11127         *ret_ref = TxOut_clone(orig_conv);
11128         return tag_ptr(ret_ref, true);
11129 }
11130
11131 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
11132         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
11133         Str_free(dummy);
11134 }
11135
11136 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
11137         LDKCVec_PublicKeyZ _res_constr;
11138         _res_constr.datalen = _res->arr_len;
11139         if (_res_constr.datalen > 0)
11140                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11141         else
11142                 _res_constr.data = NULL;
11143         int8_tArray* _res_vals = (void*) _res->elems;
11144         for (size_t m = 0; m < _res_constr.datalen; m++) {
11145                 int8_tArray _res_conv_12 = _res_vals[m];
11146                 LDKPublicKey _res_conv_12_ref;
11147                 CHECK(_res_conv_12->arr_len == 33);
11148                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
11149                 _res_constr.data[m] = _res_conv_12_ref;
11150         }
11151         FREE(_res);
11152         CVec_PublicKeyZ_free(_res_constr);
11153 }
11154
11155 uint64_t  __attribute__((export_name("TS_CResult_BlindedRouteNoneZ_ok"))) TS_CResult_BlindedRouteNoneZ_ok(uint64_t o) {
11156         LDKBlindedRoute o_conv;
11157         o_conv.inner = untag_ptr(o);
11158         o_conv.is_owned = ptr_is_owned(o);
11159         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11160         // WARNING: we need a move here but no clone is available for LDKBlindedRoute
11161         
11162         LDKCResult_BlindedRouteNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteNoneZ), "LDKCResult_BlindedRouteNoneZ");
11163         *ret_conv = CResult_BlindedRouteNoneZ_ok(o_conv);
11164         return tag_ptr(ret_conv, true);
11165 }
11166
11167 uint64_t  __attribute__((export_name("TS_CResult_BlindedRouteNoneZ_err"))) TS_CResult_BlindedRouteNoneZ_err() {
11168         LDKCResult_BlindedRouteNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteNoneZ), "LDKCResult_BlindedRouteNoneZ");
11169         *ret_conv = CResult_BlindedRouteNoneZ_err();
11170         return tag_ptr(ret_conv, true);
11171 }
11172
11173 jboolean  __attribute__((export_name("TS_CResult_BlindedRouteNoneZ_is_ok"))) TS_CResult_BlindedRouteNoneZ_is_ok(uint64_t o) {
11174         LDKCResult_BlindedRouteNoneZ* o_conv = (LDKCResult_BlindedRouteNoneZ*)untag_ptr(o);
11175         jboolean ret_conv = CResult_BlindedRouteNoneZ_is_ok(o_conv);
11176         return ret_conv;
11177 }
11178
11179 void  __attribute__((export_name("TS_CResult_BlindedRouteNoneZ_free"))) TS_CResult_BlindedRouteNoneZ_free(uint64_t _res) {
11180         if (!ptr_is_owned(_res)) return;
11181         void* _res_ptr = untag_ptr(_res);
11182         CHECK_ACCESS(_res_ptr);
11183         LDKCResult_BlindedRouteNoneZ _res_conv = *(LDKCResult_BlindedRouteNoneZ*)(_res_ptr);
11184         FREE(untag_ptr(_res));
11185         CResult_BlindedRouteNoneZ_free(_res_conv);
11186 }
11187
11188 uint64_t  __attribute__((export_name("TS_CResult_BlindedRouteDecodeErrorZ_ok"))) TS_CResult_BlindedRouteDecodeErrorZ_ok(uint64_t o) {
11189         LDKBlindedRoute o_conv;
11190         o_conv.inner = untag_ptr(o);
11191         o_conv.is_owned = ptr_is_owned(o);
11192         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11193         // WARNING: we need a move here but no clone is available for LDKBlindedRoute
11194         
11195         LDKCResult_BlindedRouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteDecodeErrorZ), "LDKCResult_BlindedRouteDecodeErrorZ");
11196         *ret_conv = CResult_BlindedRouteDecodeErrorZ_ok(o_conv);
11197         return tag_ptr(ret_conv, true);
11198 }
11199
11200 uint64_t  __attribute__((export_name("TS_CResult_BlindedRouteDecodeErrorZ_err"))) TS_CResult_BlindedRouteDecodeErrorZ_err(uint64_t e) {
11201         LDKDecodeError e_conv;
11202         e_conv.inner = untag_ptr(e);
11203         e_conv.is_owned = ptr_is_owned(e);
11204         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11205         e_conv = DecodeError_clone(&e_conv);
11206         LDKCResult_BlindedRouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteDecodeErrorZ), "LDKCResult_BlindedRouteDecodeErrorZ");
11207         *ret_conv = CResult_BlindedRouteDecodeErrorZ_err(e_conv);
11208         return tag_ptr(ret_conv, true);
11209 }
11210
11211 jboolean  __attribute__((export_name("TS_CResult_BlindedRouteDecodeErrorZ_is_ok"))) TS_CResult_BlindedRouteDecodeErrorZ_is_ok(uint64_t o) {
11212         LDKCResult_BlindedRouteDecodeErrorZ* o_conv = (LDKCResult_BlindedRouteDecodeErrorZ*)untag_ptr(o);
11213         jboolean ret_conv = CResult_BlindedRouteDecodeErrorZ_is_ok(o_conv);
11214         return ret_conv;
11215 }
11216
11217 void  __attribute__((export_name("TS_CResult_BlindedRouteDecodeErrorZ_free"))) TS_CResult_BlindedRouteDecodeErrorZ_free(uint64_t _res) {
11218         if (!ptr_is_owned(_res)) return;
11219         void* _res_ptr = untag_ptr(_res);
11220         CHECK_ACCESS(_res_ptr);
11221         LDKCResult_BlindedRouteDecodeErrorZ _res_conv = *(LDKCResult_BlindedRouteDecodeErrorZ*)(_res_ptr);
11222         FREE(untag_ptr(_res));
11223         CResult_BlindedRouteDecodeErrorZ_free(_res_conv);
11224 }
11225
11226 uint64_t  __attribute__((export_name("TS_CResult_BlindedHopDecodeErrorZ_ok"))) TS_CResult_BlindedHopDecodeErrorZ_ok(uint64_t o) {
11227         LDKBlindedHop o_conv;
11228         o_conv.inner = untag_ptr(o);
11229         o_conv.is_owned = ptr_is_owned(o);
11230         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11231         // WARNING: we need a move here but no clone is available for LDKBlindedHop
11232         
11233         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
11234         *ret_conv = CResult_BlindedHopDecodeErrorZ_ok(o_conv);
11235         return tag_ptr(ret_conv, true);
11236 }
11237
11238 uint64_t  __attribute__((export_name("TS_CResult_BlindedHopDecodeErrorZ_err"))) TS_CResult_BlindedHopDecodeErrorZ_err(uint64_t e) {
11239         LDKDecodeError e_conv;
11240         e_conv.inner = untag_ptr(e);
11241         e_conv.is_owned = ptr_is_owned(e);
11242         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11243         e_conv = DecodeError_clone(&e_conv);
11244         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
11245         *ret_conv = CResult_BlindedHopDecodeErrorZ_err(e_conv);
11246         return tag_ptr(ret_conv, true);
11247 }
11248
11249 jboolean  __attribute__((export_name("TS_CResult_BlindedHopDecodeErrorZ_is_ok"))) TS_CResult_BlindedHopDecodeErrorZ_is_ok(uint64_t o) {
11250         LDKCResult_BlindedHopDecodeErrorZ* o_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(o);
11251         jboolean ret_conv = CResult_BlindedHopDecodeErrorZ_is_ok(o_conv);
11252         return ret_conv;
11253 }
11254
11255 void  __attribute__((export_name("TS_CResult_BlindedHopDecodeErrorZ_free"))) TS_CResult_BlindedHopDecodeErrorZ_free(uint64_t _res) {
11256         if (!ptr_is_owned(_res)) return;
11257         void* _res_ptr = untag_ptr(_res);
11258         CHECK_ACCESS(_res_ptr);
11259         LDKCResult_BlindedHopDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopDecodeErrorZ*)(_res_ptr);
11260         FREE(untag_ptr(_res));
11261         CResult_BlindedHopDecodeErrorZ_free(_res_conv);
11262 }
11263
11264 uint64_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
11265         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11266         *ret_conv = CResult_NoneNoneZ_ok();
11267         return tag_ptr(ret_conv, true);
11268 }
11269
11270 uint64_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
11271         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11272         *ret_conv = CResult_NoneNoneZ_err();
11273         return tag_ptr(ret_conv, true);
11274 }
11275
11276 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint64_t o) {
11277         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)untag_ptr(o);
11278         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
11279         return ret_conv;
11280 }
11281
11282 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint64_t _res) {
11283         if (!ptr_is_owned(_res)) return;
11284         void* _res_ptr = untag_ptr(_res);
11285         CHECK_ACCESS(_res_ptr);
11286         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
11287         FREE(untag_ptr(_res));
11288         CResult_NoneNoneZ_free(_res_conv);
11289 }
11290
11291 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
11292         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11293         *ret_conv = CResult_NoneNoneZ_clone(arg);
11294         return tag_ptr(ret_conv, true);
11295 }
11296 int64_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint64_t arg) {
11297         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)untag_ptr(arg);
11298         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
11299         return ret_conv;
11300 }
11301
11302 uint64_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint64_t orig) {
11303         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)untag_ptr(orig);
11304         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11305         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
11306         return tag_ptr(ret_conv, true);
11307 }
11308
11309 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(uint64_t o) {
11310         LDKCounterpartyCommitmentSecrets o_conv;
11311         o_conv.inner = untag_ptr(o);
11312         o_conv.is_owned = ptr_is_owned(o);
11313         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11314         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
11315         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11316         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
11317         return tag_ptr(ret_conv, true);
11318 }
11319
11320 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(uint64_t e) {
11321         LDKDecodeError e_conv;
11322         e_conv.inner = untag_ptr(e);
11323         e_conv.is_owned = ptr_is_owned(e);
11324         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11325         e_conv = DecodeError_clone(&e_conv);
11326         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11327         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
11328         return tag_ptr(ret_conv, true);
11329 }
11330
11331 jboolean  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(uint64_t o) {
11332         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(o);
11333         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
11334         return ret_conv;
11335 }
11336
11337 void  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(uint64_t _res) {
11338         if (!ptr_is_owned(_res)) return;
11339         void* _res_ptr = untag_ptr(_res);
11340         CHECK_ACCESS(_res_ptr);
11341         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
11342         FREE(untag_ptr(_res));
11343         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
11344 }
11345
11346 static inline uint64_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
11347         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11348         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
11349         return tag_ptr(ret_conv, true);
11350 }
11351 int64_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(uint64_t arg) {
11352         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(arg);
11353         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
11354         return ret_conv;
11355 }
11356
11357 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(uint64_t orig) {
11358         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(orig);
11359         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11360         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
11361         return tag_ptr(ret_conv, true);
11362 }
11363
11364 uint64_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
11365         LDKSecretKey o_ref;
11366         CHECK(o->arr_len == 32);
11367         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
11368         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11369         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
11370         return tag_ptr(ret_conv, true);
11371 }
11372
11373 uint64_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
11374         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11375         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11376         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
11377         return tag_ptr(ret_conv, true);
11378 }
11379
11380 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint64_t o) {
11381         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(o);
11382         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
11383         return ret_conv;
11384 }
11385
11386 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint64_t _res) {
11387         if (!ptr_is_owned(_res)) return;
11388         void* _res_ptr = untag_ptr(_res);
11389         CHECK_ACCESS(_res_ptr);
11390         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
11391         FREE(untag_ptr(_res));
11392         CResult_SecretKeyErrorZ_free(_res_conv);
11393 }
11394
11395 static inline uint64_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
11396         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11397         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
11398         return tag_ptr(ret_conv, true);
11399 }
11400 int64_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone_ptr"))) TS_CResult_SecretKeyErrorZ_clone_ptr(uint64_t arg) {
11401         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(arg);
11402         int64_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
11403         return ret_conv;
11404 }
11405
11406 uint64_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone"))) TS_CResult_SecretKeyErrorZ_clone(uint64_t orig) {
11407         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(orig);
11408         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11409         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
11410         return tag_ptr(ret_conv, true);
11411 }
11412
11413 uint64_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
11414         LDKPublicKey o_ref;
11415         CHECK(o->arr_len == 33);
11416         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
11417         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11418         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
11419         return tag_ptr(ret_conv, true);
11420 }
11421
11422 uint64_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
11423         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11424         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11425         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
11426         return tag_ptr(ret_conv, true);
11427 }
11428
11429 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint64_t o) {
11430         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(o);
11431         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
11432         return ret_conv;
11433 }
11434
11435 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint64_t _res) {
11436         if (!ptr_is_owned(_res)) return;
11437         void* _res_ptr = untag_ptr(_res);
11438         CHECK_ACCESS(_res_ptr);
11439         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
11440         FREE(untag_ptr(_res));
11441         CResult_PublicKeyErrorZ_free(_res_conv);
11442 }
11443
11444 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
11445         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11446         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
11447         return tag_ptr(ret_conv, true);
11448 }
11449 int64_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint64_t arg) {
11450         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(arg);
11451         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
11452         return ret_conv;
11453 }
11454
11455 uint64_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint64_t orig) {
11456         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(orig);
11457         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11458         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
11459         return tag_ptr(ret_conv, true);
11460 }
11461
11462 uint64_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint64_t o) {
11463         LDKTxCreationKeys o_conv;
11464         o_conv.inner = untag_ptr(o);
11465         o_conv.is_owned = ptr_is_owned(o);
11466         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11467         o_conv = TxCreationKeys_clone(&o_conv);
11468         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11469         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
11470         return tag_ptr(ret_conv, true);
11471 }
11472
11473 uint64_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint64_t e) {
11474         LDKDecodeError e_conv;
11475         e_conv.inner = untag_ptr(e);
11476         e_conv.is_owned = ptr_is_owned(e);
11477         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11478         e_conv = DecodeError_clone(&e_conv);
11479         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11480         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
11481         return tag_ptr(ret_conv, true);
11482 }
11483
11484 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint64_t o) {
11485         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(o);
11486         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
11487         return ret_conv;
11488 }
11489
11490 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint64_t _res) {
11491         if (!ptr_is_owned(_res)) return;
11492         void* _res_ptr = untag_ptr(_res);
11493         CHECK_ACCESS(_res_ptr);
11494         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
11495         FREE(untag_ptr(_res));
11496         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
11497 }
11498
11499 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
11500         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11501         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
11502         return tag_ptr(ret_conv, true);
11503 }
11504 int64_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint64_t arg) {
11505         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(arg);
11506         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
11507         return ret_conv;
11508 }
11509
11510 uint64_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint64_t orig) {
11511         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(orig);
11512         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11513         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
11514         return tag_ptr(ret_conv, true);
11515 }
11516
11517 uint64_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint64_t o) {
11518         LDKChannelPublicKeys o_conv;
11519         o_conv.inner = untag_ptr(o);
11520         o_conv.is_owned = ptr_is_owned(o);
11521         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11522         o_conv = ChannelPublicKeys_clone(&o_conv);
11523         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11524         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
11525         return tag_ptr(ret_conv, true);
11526 }
11527
11528 uint64_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint64_t e) {
11529         LDKDecodeError e_conv;
11530         e_conv.inner = untag_ptr(e);
11531         e_conv.is_owned = ptr_is_owned(e);
11532         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11533         e_conv = DecodeError_clone(&e_conv);
11534         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11535         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
11536         return tag_ptr(ret_conv, true);
11537 }
11538
11539 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint64_t o) {
11540         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(o);
11541         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
11542         return ret_conv;
11543 }
11544
11545 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint64_t _res) {
11546         if (!ptr_is_owned(_res)) return;
11547         void* _res_ptr = untag_ptr(_res);
11548         CHECK_ACCESS(_res_ptr);
11549         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
11550         FREE(untag_ptr(_res));
11551         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
11552 }
11553
11554 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
11555         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11556         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
11557         return tag_ptr(ret_conv, true);
11558 }
11559 int64_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint64_t arg) {
11560         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(arg);
11561         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
11562         return ret_conv;
11563 }
11564
11565 uint64_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint64_t orig) {
11566         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(orig);
11567         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11568         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
11569         return tag_ptr(ret_conv, true);
11570 }
11571
11572 uint64_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint64_t o) {
11573         LDKTxCreationKeys o_conv;
11574         o_conv.inner = untag_ptr(o);
11575         o_conv.is_owned = ptr_is_owned(o);
11576         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11577         o_conv = TxCreationKeys_clone(&o_conv);
11578         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11579         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
11580         return tag_ptr(ret_conv, true);
11581 }
11582
11583 uint64_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
11584         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11585         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11586         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
11587         return tag_ptr(ret_conv, true);
11588 }
11589
11590 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint64_t o) {
11591         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(o);
11592         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
11593         return ret_conv;
11594 }
11595
11596 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint64_t _res) {
11597         if (!ptr_is_owned(_res)) return;
11598         void* _res_ptr = untag_ptr(_res);
11599         CHECK_ACCESS(_res_ptr);
11600         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
11601         FREE(untag_ptr(_res));
11602         CResult_TxCreationKeysErrorZ_free(_res_conv);
11603 }
11604
11605 static inline uint64_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
11606         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11607         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
11608         return tag_ptr(ret_conv, true);
11609 }
11610 int64_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint64_t arg) {
11611         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(arg);
11612         int64_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
11613         return ret_conv;
11614 }
11615
11616 uint64_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint64_t orig) {
11617         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(orig);
11618         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11619         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
11620         return tag_ptr(ret_conv, true);
11621 }
11622
11623 uint64_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
11624         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11625         *ret_copy = COption_u32Z_some(o);
11626         uint64_t ret_ref = tag_ptr(ret_copy, true);
11627         return ret_ref;
11628 }
11629
11630 uint64_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
11631         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11632         *ret_copy = COption_u32Z_none();
11633         uint64_t ret_ref = tag_ptr(ret_copy, true);
11634         return ret_ref;
11635 }
11636
11637 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint64_t _res) {
11638         if (!ptr_is_owned(_res)) return;
11639         void* _res_ptr = untag_ptr(_res);
11640         CHECK_ACCESS(_res_ptr);
11641         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
11642         FREE(untag_ptr(_res));
11643         COption_u32Z_free(_res_conv);
11644 }
11645
11646 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
11647         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11648         *ret_copy = COption_u32Z_clone(arg);
11649         uint64_t ret_ref = tag_ptr(ret_copy, true);
11650         return ret_ref;
11651 }
11652 int64_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint64_t arg) {
11653         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)untag_ptr(arg);
11654         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
11655         return ret_conv;
11656 }
11657
11658 uint64_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint64_t orig) {
11659         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)untag_ptr(orig);
11660         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11661         *ret_copy = COption_u32Z_clone(orig_conv);
11662         uint64_t ret_ref = tag_ptr(ret_copy, true);
11663         return ret_ref;
11664 }
11665
11666 uint64_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint64_t o) {
11667         LDKHTLCOutputInCommitment o_conv;
11668         o_conv.inner = untag_ptr(o);
11669         o_conv.is_owned = ptr_is_owned(o);
11670         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11671         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11672         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11673         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11674         return tag_ptr(ret_conv, true);
11675 }
11676
11677 uint64_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint64_t e) {
11678         LDKDecodeError e_conv;
11679         e_conv.inner = untag_ptr(e);
11680         e_conv.is_owned = ptr_is_owned(e);
11681         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11682         e_conv = DecodeError_clone(&e_conv);
11683         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11684         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11685         return tag_ptr(ret_conv, true);
11686 }
11687
11688 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint64_t o) {
11689         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(o);
11690         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
11691         return ret_conv;
11692 }
11693
11694 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint64_t _res) {
11695         if (!ptr_is_owned(_res)) return;
11696         void* _res_ptr = untag_ptr(_res);
11697         CHECK_ACCESS(_res_ptr);
11698         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11699         FREE(untag_ptr(_res));
11700         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11701 }
11702
11703 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
11704         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11705         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
11706         return tag_ptr(ret_conv, true);
11707 }
11708 int64_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint64_t arg) {
11709         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(arg);
11710         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
11711         return ret_conv;
11712 }
11713
11714 uint64_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint64_t orig) {
11715         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(orig);
11716         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11717         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11718         return tag_ptr(ret_conv, true);
11719 }
11720
11721 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
11722         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
11723         return ret_conv;
11724 }
11725
11726 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
11727         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
11728         return ret_conv;
11729 }
11730
11731 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
11732         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
11733         COption_NoneZ_free(_res_conv);
11734 }
11735
11736 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint64_t o) {
11737         LDKCounterpartyChannelTransactionParameters o_conv;
11738         o_conv.inner = untag_ptr(o);
11739         o_conv.is_owned = ptr_is_owned(o);
11740         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11741         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11742         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11743         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11744         return tag_ptr(ret_conv, true);
11745 }
11746
11747 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint64_t e) {
11748         LDKDecodeError e_conv;
11749         e_conv.inner = untag_ptr(e);
11750         e_conv.is_owned = ptr_is_owned(e);
11751         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11752         e_conv = DecodeError_clone(&e_conv);
11753         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11754         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11755         return tag_ptr(ret_conv, true);
11756 }
11757
11758 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint64_t o) {
11759         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
11760         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11761         return ret_conv;
11762 }
11763
11764 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint64_t _res) {
11765         if (!ptr_is_owned(_res)) return;
11766         void* _res_ptr = untag_ptr(_res);
11767         CHECK_ACCESS(_res_ptr);
11768         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11769         FREE(untag_ptr(_res));
11770         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11771 }
11772
11773 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11774         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11775         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
11776         return tag_ptr(ret_conv, true);
11777 }
11778 int64_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint64_t arg) {
11779         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
11780         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11781         return ret_conv;
11782 }
11783
11784 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint64_t orig) {
11785         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
11786         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11787         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11788         return tag_ptr(ret_conv, true);
11789 }
11790
11791 uint64_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint64_t o) {
11792         LDKChannelTransactionParameters o_conv;
11793         o_conv.inner = untag_ptr(o);
11794         o_conv.is_owned = ptr_is_owned(o);
11795         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11796         o_conv = ChannelTransactionParameters_clone(&o_conv);
11797         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11798         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11799         return tag_ptr(ret_conv, true);
11800 }
11801
11802 uint64_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint64_t e) {
11803         LDKDecodeError e_conv;
11804         e_conv.inner = untag_ptr(e);
11805         e_conv.is_owned = ptr_is_owned(e);
11806         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11807         e_conv = DecodeError_clone(&e_conv);
11808         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11809         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11810         return tag_ptr(ret_conv, true);
11811 }
11812
11813 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint64_t o) {
11814         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
11815         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11816         return ret_conv;
11817 }
11818
11819 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint64_t _res) {
11820         if (!ptr_is_owned(_res)) return;
11821         void* _res_ptr = untag_ptr(_res);
11822         CHECK_ACCESS(_res_ptr);
11823         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11824         FREE(untag_ptr(_res));
11825         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11826 }
11827
11828 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11829         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11830         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
11831         return tag_ptr(ret_conv, true);
11832 }
11833 int64_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint64_t arg) {
11834         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
11835         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11836         return ret_conv;
11837 }
11838
11839 uint64_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint64_t orig) {
11840         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
11841         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11842         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11843         return tag_ptr(ret_conv, true);
11844 }
11845
11846 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
11847         LDKCVec_SignatureZ _res_constr;
11848         _res_constr.datalen = _res->arr_len;
11849         if (_res_constr.datalen > 0)
11850                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11851         else
11852                 _res_constr.data = NULL;
11853         int8_tArray* _res_vals = (void*) _res->elems;
11854         for (size_t m = 0; m < _res_constr.datalen; m++) {
11855                 int8_tArray _res_conv_12 = _res_vals[m];
11856                 LDKSignature _res_conv_12_ref;
11857                 CHECK(_res_conv_12->arr_len == 64);
11858                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
11859                 _res_constr.data[m] = _res_conv_12_ref;
11860         }
11861         FREE(_res);
11862         CVec_SignatureZ_free(_res_constr);
11863 }
11864
11865 uint64_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint64_t o) {
11866         LDKHolderCommitmentTransaction o_conv;
11867         o_conv.inner = untag_ptr(o);
11868         o_conv.is_owned = ptr_is_owned(o);
11869         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11870         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11871         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11872         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11873         return tag_ptr(ret_conv, true);
11874 }
11875
11876 uint64_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint64_t e) {
11877         LDKDecodeError e_conv;
11878         e_conv.inner = untag_ptr(e);
11879         e_conv.is_owned = ptr_is_owned(e);
11880         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11881         e_conv = DecodeError_clone(&e_conv);
11882         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11883         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11884         return tag_ptr(ret_conv, true);
11885 }
11886
11887 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint64_t o) {
11888         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
11889         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11890         return ret_conv;
11891 }
11892
11893 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint64_t _res) {
11894         if (!ptr_is_owned(_res)) return;
11895         void* _res_ptr = untag_ptr(_res);
11896         CHECK_ACCESS(_res_ptr);
11897         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11898         FREE(untag_ptr(_res));
11899         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
11900 }
11901
11902 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11903         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11904         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
11905         return tag_ptr(ret_conv, true);
11906 }
11907 int64_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint64_t arg) {
11908         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
11909         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11910         return ret_conv;
11911 }
11912
11913 uint64_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint64_t orig) {
11914         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
11915         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11916         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11917         return tag_ptr(ret_conv, true);
11918 }
11919
11920 uint64_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint64_t o) {
11921         LDKBuiltCommitmentTransaction o_conv;
11922         o_conv.inner = untag_ptr(o);
11923         o_conv.is_owned = ptr_is_owned(o);
11924         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11925         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
11926         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11927         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
11928         return tag_ptr(ret_conv, true);
11929 }
11930
11931 uint64_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint64_t e) {
11932         LDKDecodeError e_conv;
11933         e_conv.inner = untag_ptr(e);
11934         e_conv.is_owned = ptr_is_owned(e);
11935         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11936         e_conv = DecodeError_clone(&e_conv);
11937         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11938         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
11939         return tag_ptr(ret_conv, true);
11940 }
11941
11942 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint64_t o) {
11943         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
11944         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11945         return ret_conv;
11946 }
11947
11948 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint64_t _res) {
11949         if (!ptr_is_owned(_res)) return;
11950         void* _res_ptr = untag_ptr(_res);
11951         CHECK_ACCESS(_res_ptr);
11952         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11953         FREE(untag_ptr(_res));
11954         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
11955 }
11956
11957 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11958         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11959         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
11960         return tag_ptr(ret_conv, true);
11961 }
11962 int64_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint64_t arg) {
11963         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
11964         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11965         return ret_conv;
11966 }
11967
11968 uint64_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint64_t orig) {
11969         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
11970         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11971         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11972         return tag_ptr(ret_conv, true);
11973 }
11974
11975 uint64_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint64_t o) {
11976         LDKTrustedClosingTransaction o_conv;
11977         o_conv.inner = untag_ptr(o);
11978         o_conv.is_owned = ptr_is_owned(o);
11979         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11980         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
11981         
11982         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11983         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
11984         return tag_ptr(ret_conv, true);
11985 }
11986
11987 uint64_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
11988         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11989         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
11990         return tag_ptr(ret_conv, true);
11991 }
11992
11993 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint64_t o) {
11994         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(o);
11995         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
11996         return ret_conv;
11997 }
11998
11999 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint64_t _res) {
12000         if (!ptr_is_owned(_res)) return;
12001         void* _res_ptr = untag_ptr(_res);
12002         CHECK_ACCESS(_res_ptr);
12003         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
12004         FREE(untag_ptr(_res));
12005         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
12006 }
12007
12008 uint64_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint64_t o) {
12009         LDKCommitmentTransaction o_conv;
12010         o_conv.inner = untag_ptr(o);
12011         o_conv.is_owned = ptr_is_owned(o);
12012         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12013         o_conv = CommitmentTransaction_clone(&o_conv);
12014         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12015         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
12016         return tag_ptr(ret_conv, true);
12017 }
12018
12019 uint64_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint64_t e) {
12020         LDKDecodeError e_conv;
12021         e_conv.inner = untag_ptr(e);
12022         e_conv.is_owned = ptr_is_owned(e);
12023         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12024         e_conv = DecodeError_clone(&e_conv);
12025         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12026         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
12027         return tag_ptr(ret_conv, true);
12028 }
12029
12030 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint64_t o) {
12031         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(o);
12032         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
12033         return ret_conv;
12034 }
12035
12036 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint64_t _res) {
12037         if (!ptr_is_owned(_res)) return;
12038         void* _res_ptr = untag_ptr(_res);
12039         CHECK_ACCESS(_res_ptr);
12040         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
12041         FREE(untag_ptr(_res));
12042         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
12043 }
12044
12045 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
12046         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12047         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
12048         return tag_ptr(ret_conv, true);
12049 }
12050 int64_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint64_t arg) {
12051         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
12052         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
12053         return ret_conv;
12054 }
12055
12056 uint64_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint64_t orig) {
12057         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
12058         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12059         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
12060         return tag_ptr(ret_conv, true);
12061 }
12062
12063 uint64_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint64_t o) {
12064         LDKTrustedCommitmentTransaction o_conv;
12065         o_conv.inner = untag_ptr(o);
12066         o_conv.is_owned = ptr_is_owned(o);
12067         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12068         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
12069         
12070         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
12071         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
12072         return tag_ptr(ret_conv, true);
12073 }
12074
12075 uint64_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
12076         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
12077         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
12078         return tag_ptr(ret_conv, true);
12079 }
12080
12081 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint64_t o) {
12082         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(o);
12083         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
12084         return ret_conv;
12085 }
12086
12087 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint64_t _res) {
12088         if (!ptr_is_owned(_res)) return;
12089         void* _res_ptr = untag_ptr(_res);
12090         CHECK_ACCESS(_res_ptr);
12091         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
12092         FREE(untag_ptr(_res));
12093         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
12094 }
12095
12096 uint64_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
12097         LDKCVec_SignatureZ o_constr;
12098         o_constr.datalen = o->arr_len;
12099         if (o_constr.datalen > 0)
12100                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
12101         else
12102                 o_constr.data = NULL;
12103         int8_tArray* o_vals = (void*) o->elems;
12104         for (size_t m = 0; m < o_constr.datalen; m++) {
12105                 int8_tArray o_conv_12 = o_vals[m];
12106                 LDKSignature o_conv_12_ref;
12107                 CHECK(o_conv_12->arr_len == 64);
12108                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
12109                 o_constr.data[m] = o_conv_12_ref;
12110         }
12111         FREE(o);
12112         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12113         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
12114         return tag_ptr(ret_conv, true);
12115 }
12116
12117 uint64_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
12118         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12119         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
12120         return tag_ptr(ret_conv, true);
12121 }
12122
12123 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint64_t o) {
12124         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(o);
12125         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
12126         return ret_conv;
12127 }
12128
12129 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint64_t _res) {
12130         if (!ptr_is_owned(_res)) return;
12131         void* _res_ptr = untag_ptr(_res);
12132         CHECK_ACCESS(_res_ptr);
12133         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
12134         FREE(untag_ptr(_res));
12135         CResult_CVec_SignatureZNoneZ_free(_res_conv);
12136 }
12137
12138 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
12139         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12140         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
12141         return tag_ptr(ret_conv, true);
12142 }
12143 int64_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint64_t arg) {
12144         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(arg);
12145         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
12146         return ret_conv;
12147 }
12148
12149 uint64_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint64_t orig) {
12150         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(orig);
12151         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12152         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
12153         return tag_ptr(ret_conv, true);
12154 }
12155
12156 uint64_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint64_t o) {
12157         LDKShutdownScript o_conv;
12158         o_conv.inner = untag_ptr(o);
12159         o_conv.is_owned = ptr_is_owned(o);
12160         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12161         o_conv = ShutdownScript_clone(&o_conv);
12162         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12163         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
12164         return tag_ptr(ret_conv, true);
12165 }
12166
12167 uint64_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint64_t e) {
12168         LDKDecodeError e_conv;
12169         e_conv.inner = untag_ptr(e);
12170         e_conv.is_owned = ptr_is_owned(e);
12171         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12172         e_conv = DecodeError_clone(&e_conv);
12173         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12174         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
12175         return tag_ptr(ret_conv, true);
12176 }
12177
12178 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint64_t o) {
12179         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(o);
12180         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
12181         return ret_conv;
12182 }
12183
12184 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint64_t _res) {
12185         if (!ptr_is_owned(_res)) return;
12186         void* _res_ptr = untag_ptr(_res);
12187         CHECK_ACCESS(_res_ptr);
12188         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
12189         FREE(untag_ptr(_res));
12190         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
12191 }
12192
12193 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
12194         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12195         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
12196         return tag_ptr(ret_conv, true);
12197 }
12198 int64_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint64_t arg) {
12199         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(arg);
12200         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
12201         return ret_conv;
12202 }
12203
12204 uint64_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint64_t orig) {
12205         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(orig);
12206         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12207         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
12208         return tag_ptr(ret_conv, true);
12209 }
12210
12211 uint64_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint64_t o) {
12212         LDKShutdownScript o_conv;
12213         o_conv.inner = untag_ptr(o);
12214         o_conv.is_owned = ptr_is_owned(o);
12215         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12216         o_conv = ShutdownScript_clone(&o_conv);
12217         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12218         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
12219         return tag_ptr(ret_conv, true);
12220 }
12221
12222 uint64_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint64_t e) {
12223         LDKInvalidShutdownScript e_conv;
12224         e_conv.inner = untag_ptr(e);
12225         e_conv.is_owned = ptr_is_owned(e);
12226         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12227         e_conv = InvalidShutdownScript_clone(&e_conv);
12228         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12229         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
12230         return tag_ptr(ret_conv, true);
12231 }
12232
12233 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint64_t o) {
12234         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(o);
12235         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
12236         return ret_conv;
12237 }
12238
12239 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint64_t _res) {
12240         if (!ptr_is_owned(_res)) return;
12241         void* _res_ptr = untag_ptr(_res);
12242         CHECK_ACCESS(_res_ptr);
12243         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
12244         FREE(untag_ptr(_res));
12245         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
12246 }
12247
12248 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
12249         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12250         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
12251         return tag_ptr(ret_conv, true);
12252 }
12253 int64_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint64_t arg) {
12254         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(arg);
12255         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
12256         return ret_conv;
12257 }
12258
12259 uint64_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint64_t orig) {
12260         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(orig);
12261         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12262         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
12263         return tag_ptr(ret_conv, true);
12264 }
12265
12266 uint64_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint64_t o) {
12267         LDKRouteHop o_conv;
12268         o_conv.inner = untag_ptr(o);
12269         o_conv.is_owned = ptr_is_owned(o);
12270         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12271         o_conv = RouteHop_clone(&o_conv);
12272         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12273         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
12274         return tag_ptr(ret_conv, true);
12275 }
12276
12277 uint64_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint64_t e) {
12278         LDKDecodeError e_conv;
12279         e_conv.inner = untag_ptr(e);
12280         e_conv.is_owned = ptr_is_owned(e);
12281         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12282         e_conv = DecodeError_clone(&e_conv);
12283         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12284         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
12285         return tag_ptr(ret_conv, true);
12286 }
12287
12288 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint64_t o) {
12289         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(o);
12290         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
12291         return ret_conv;
12292 }
12293
12294 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint64_t _res) {
12295         if (!ptr_is_owned(_res)) return;
12296         void* _res_ptr = untag_ptr(_res);
12297         CHECK_ACCESS(_res_ptr);
12298         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
12299         FREE(untag_ptr(_res));
12300         CResult_RouteHopDecodeErrorZ_free(_res_conv);
12301 }
12302
12303 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
12304         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12305         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
12306         return tag_ptr(ret_conv, true);
12307 }
12308 int64_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint64_t arg) {
12309         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(arg);
12310         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
12311         return ret_conv;
12312 }
12313
12314 uint64_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint64_t orig) {
12315         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(orig);
12316         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12317         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
12318         return tag_ptr(ret_conv, true);
12319 }
12320
12321 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint64_tArray _res) {
12322         LDKCVec_RouteHopZ _res_constr;
12323         _res_constr.datalen = _res->arr_len;
12324         if (_res_constr.datalen > 0)
12325                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12326         else
12327                 _res_constr.data = NULL;
12328         uint64_t* _res_vals = _res->elems;
12329         for (size_t k = 0; k < _res_constr.datalen; k++) {
12330                 uint64_t _res_conv_10 = _res_vals[k];
12331                 LDKRouteHop _res_conv_10_conv;
12332                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
12333                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
12334                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
12335                 _res_constr.data[k] = _res_conv_10_conv;
12336         }
12337         FREE(_res);
12338         CVec_RouteHopZ_free(_res_constr);
12339 }
12340
12341 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
12342         LDKCVec_CVec_RouteHopZZ _res_constr;
12343         _res_constr.datalen = _res->arr_len;
12344         if (_res_constr.datalen > 0)
12345                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12346         else
12347                 _res_constr.data = NULL;
12348         uint64_tArray* _res_vals = (void*) _res->elems;
12349         for (size_t m = 0; m < _res_constr.datalen; m++) {
12350                 uint64_tArray _res_conv_12 = _res_vals[m];
12351                 LDKCVec_RouteHopZ _res_conv_12_constr;
12352                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
12353                 if (_res_conv_12_constr.datalen > 0)
12354                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12355                 else
12356                         _res_conv_12_constr.data = NULL;
12357                 uint64_t* _res_conv_12_vals = _res_conv_12->elems;
12358                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
12359                         uint64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
12360                         LDKRouteHop _res_conv_12_conv_10_conv;
12361                         _res_conv_12_conv_10_conv.inner = untag_ptr(_res_conv_12_conv_10);
12362                         _res_conv_12_conv_10_conv.is_owned = ptr_is_owned(_res_conv_12_conv_10);
12363                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
12364                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
12365                 }
12366                 FREE(_res_conv_12);
12367                 _res_constr.data[m] = _res_conv_12_constr;
12368         }
12369         FREE(_res);
12370         CVec_CVec_RouteHopZZ_free(_res_constr);
12371 }
12372
12373 uint64_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint64_t o) {
12374         LDKRoute o_conv;
12375         o_conv.inner = untag_ptr(o);
12376         o_conv.is_owned = ptr_is_owned(o);
12377         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12378         o_conv = Route_clone(&o_conv);
12379         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12380         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
12381         return tag_ptr(ret_conv, true);
12382 }
12383
12384 uint64_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint64_t e) {
12385         LDKDecodeError e_conv;
12386         e_conv.inner = untag_ptr(e);
12387         e_conv.is_owned = ptr_is_owned(e);
12388         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12389         e_conv = DecodeError_clone(&e_conv);
12390         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12391         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
12392         return tag_ptr(ret_conv, true);
12393 }
12394
12395 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint64_t o) {
12396         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(o);
12397         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
12398         return ret_conv;
12399 }
12400
12401 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint64_t _res) {
12402         if (!ptr_is_owned(_res)) return;
12403         void* _res_ptr = untag_ptr(_res);
12404         CHECK_ACCESS(_res_ptr);
12405         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
12406         FREE(untag_ptr(_res));
12407         CResult_RouteDecodeErrorZ_free(_res_conv);
12408 }
12409
12410 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
12411         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12412         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
12413         return tag_ptr(ret_conv, true);
12414 }
12415 int64_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint64_t arg) {
12416         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(arg);
12417         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
12418         return ret_conv;
12419 }
12420
12421 uint64_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint64_t orig) {
12422         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(orig);
12423         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12424         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
12425         return tag_ptr(ret_conv, true);
12426 }
12427
12428 uint64_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint64_t o) {
12429         LDKRouteParameters o_conv;
12430         o_conv.inner = untag_ptr(o);
12431         o_conv.is_owned = ptr_is_owned(o);
12432         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12433         o_conv = RouteParameters_clone(&o_conv);
12434         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12435         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
12436         return tag_ptr(ret_conv, true);
12437 }
12438
12439 uint64_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint64_t e) {
12440         LDKDecodeError e_conv;
12441         e_conv.inner = untag_ptr(e);
12442         e_conv.is_owned = ptr_is_owned(e);
12443         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12444         e_conv = DecodeError_clone(&e_conv);
12445         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12446         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
12447         return tag_ptr(ret_conv, true);
12448 }
12449
12450 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint64_t o) {
12451         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(o);
12452         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
12453         return ret_conv;
12454 }
12455
12456 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint64_t _res) {
12457         if (!ptr_is_owned(_res)) return;
12458         void* _res_ptr = untag_ptr(_res);
12459         CHECK_ACCESS(_res_ptr);
12460         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
12461         FREE(untag_ptr(_res));
12462         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
12463 }
12464
12465 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
12466         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12467         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
12468         return tag_ptr(ret_conv, true);
12469 }
12470 int64_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint64_t arg) {
12471         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(arg);
12472         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
12473         return ret_conv;
12474 }
12475
12476 uint64_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint64_t orig) {
12477         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(orig);
12478         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12479         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
12480         return tag_ptr(ret_conv, true);
12481 }
12482
12483 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint64_tArray _res) {
12484         LDKCVec_RouteHintZ _res_constr;
12485         _res_constr.datalen = _res->arr_len;
12486         if (_res_constr.datalen > 0)
12487                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
12488         else
12489                 _res_constr.data = NULL;
12490         uint64_t* _res_vals = _res->elems;
12491         for (size_t l = 0; l < _res_constr.datalen; l++) {
12492                 uint64_t _res_conv_11 = _res_vals[l];
12493                 LDKRouteHint _res_conv_11_conv;
12494                 _res_conv_11_conv.inner = untag_ptr(_res_conv_11);
12495                 _res_conv_11_conv.is_owned = ptr_is_owned(_res_conv_11);
12496                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
12497                 _res_constr.data[l] = _res_conv_11_conv;
12498         }
12499         FREE(_res);
12500         CVec_RouteHintZ_free(_res_constr);
12501 }
12502
12503 uint64_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
12504         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12505         *ret_copy = COption_u64Z_some(o);
12506         uint64_t ret_ref = tag_ptr(ret_copy, true);
12507         return ret_ref;
12508 }
12509
12510 uint64_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
12511         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12512         *ret_copy = COption_u64Z_none();
12513         uint64_t ret_ref = tag_ptr(ret_copy, true);
12514         return ret_ref;
12515 }
12516
12517 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint64_t _res) {
12518         if (!ptr_is_owned(_res)) return;
12519         void* _res_ptr = untag_ptr(_res);
12520         CHECK_ACCESS(_res_ptr);
12521         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
12522         FREE(untag_ptr(_res));
12523         COption_u64Z_free(_res_conv);
12524 }
12525
12526 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
12527         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12528         *ret_copy = COption_u64Z_clone(arg);
12529         uint64_t ret_ref = tag_ptr(ret_copy, true);
12530         return ret_ref;
12531 }
12532 int64_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint64_t arg) {
12533         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)untag_ptr(arg);
12534         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
12535         return ret_conv;
12536 }
12537
12538 uint64_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint64_t orig) {
12539         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)untag_ptr(orig);
12540         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12541         *ret_copy = COption_u64Z_clone(orig_conv);
12542         uint64_t ret_ref = tag_ptr(ret_copy, true);
12543         return ret_ref;
12544 }
12545
12546 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
12547         LDKCVec_u64Z _res_constr;
12548         _res_constr.datalen = _res->arr_len;
12549         if (_res_constr.datalen > 0)
12550                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
12551         else
12552                 _res_constr.data = NULL;
12553         int64_t* _res_vals = _res->elems;
12554         for (size_t i = 0; i < _res_constr.datalen; i++) {
12555                 int64_t _res_conv_8 = _res_vals[i];
12556                 _res_constr.data[i] = _res_conv_8;
12557         }
12558         FREE(_res);
12559         CVec_u64Z_free(_res_constr);
12560 }
12561
12562 uint64_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_ok(uint64_t o) {
12563         LDKPaymentParameters o_conv;
12564         o_conv.inner = untag_ptr(o);
12565         o_conv.is_owned = ptr_is_owned(o);
12566         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12567         o_conv = PaymentParameters_clone(&o_conv);
12568         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12569         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
12570         return tag_ptr(ret_conv, true);
12571 }
12572
12573 uint64_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_err"))) TS_CResult_PaymentParametersDecodeErrorZ_err(uint64_t e) {
12574         LDKDecodeError e_conv;
12575         e_conv.inner = untag_ptr(e);
12576         e_conv.is_owned = ptr_is_owned(e);
12577         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12578         e_conv = DecodeError_clone(&e_conv);
12579         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12580         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
12581         return tag_ptr(ret_conv, true);
12582 }
12583
12584 jboolean  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_is_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_is_ok(uint64_t o) {
12585         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(o);
12586         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
12587         return ret_conv;
12588 }
12589
12590 void  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_free"))) TS_CResult_PaymentParametersDecodeErrorZ_free(uint64_t _res) {
12591         if (!ptr_is_owned(_res)) return;
12592         void* _res_ptr = untag_ptr(_res);
12593         CHECK_ACCESS(_res_ptr);
12594         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
12595         FREE(untag_ptr(_res));
12596         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
12597 }
12598
12599 static inline uint64_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
12600         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12601         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
12602         return tag_ptr(ret_conv, true);
12603 }
12604 int64_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr(uint64_t arg) {
12605         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(arg);
12606         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
12607         return ret_conv;
12608 }
12609
12610 uint64_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone"))) TS_CResult_PaymentParametersDecodeErrorZ_clone(uint64_t orig) {
12611         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(orig);
12612         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12613         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
12614         return tag_ptr(ret_conv, true);
12615 }
12616
12617 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint64_tArray _res) {
12618         LDKCVec_RouteHintHopZ _res_constr;
12619         _res_constr.datalen = _res->arr_len;
12620         if (_res_constr.datalen > 0)
12621                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
12622         else
12623                 _res_constr.data = NULL;
12624         uint64_t* _res_vals = _res->elems;
12625         for (size_t o = 0; o < _res_constr.datalen; o++) {
12626                 uint64_t _res_conv_14 = _res_vals[o];
12627                 LDKRouteHintHop _res_conv_14_conv;
12628                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
12629                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
12630                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
12631                 _res_constr.data[o] = _res_conv_14_conv;
12632         }
12633         FREE(_res);
12634         CVec_RouteHintHopZ_free(_res_constr);
12635 }
12636
12637 uint64_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint64_t o) {
12638         LDKRouteHint o_conv;
12639         o_conv.inner = untag_ptr(o);
12640         o_conv.is_owned = ptr_is_owned(o);
12641         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12642         o_conv = RouteHint_clone(&o_conv);
12643         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12644         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
12645         return tag_ptr(ret_conv, true);
12646 }
12647
12648 uint64_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint64_t e) {
12649         LDKDecodeError e_conv;
12650         e_conv.inner = untag_ptr(e);
12651         e_conv.is_owned = ptr_is_owned(e);
12652         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12653         e_conv = DecodeError_clone(&e_conv);
12654         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12655         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
12656         return tag_ptr(ret_conv, true);
12657 }
12658
12659 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint64_t o) {
12660         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(o);
12661         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
12662         return ret_conv;
12663 }
12664
12665 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint64_t _res) {
12666         if (!ptr_is_owned(_res)) return;
12667         void* _res_ptr = untag_ptr(_res);
12668         CHECK_ACCESS(_res_ptr);
12669         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
12670         FREE(untag_ptr(_res));
12671         CResult_RouteHintDecodeErrorZ_free(_res_conv);
12672 }
12673
12674 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
12675         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12676         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
12677         return tag_ptr(ret_conv, true);
12678 }
12679 int64_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint64_t arg) {
12680         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(arg);
12681         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
12682         return ret_conv;
12683 }
12684
12685 uint64_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint64_t orig) {
12686         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(orig);
12687         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12688         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12689         return tag_ptr(ret_conv, true);
12690 }
12691
12692 uint64_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint64_t o) {
12693         LDKRouteHintHop o_conv;
12694         o_conv.inner = untag_ptr(o);
12695         o_conv.is_owned = ptr_is_owned(o);
12696         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12697         o_conv = RouteHintHop_clone(&o_conv);
12698         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12699         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12700         return tag_ptr(ret_conv, true);
12701 }
12702
12703 uint64_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint64_t e) {
12704         LDKDecodeError e_conv;
12705         e_conv.inner = untag_ptr(e);
12706         e_conv.is_owned = ptr_is_owned(e);
12707         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12708         e_conv = DecodeError_clone(&e_conv);
12709         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12710         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12711         return tag_ptr(ret_conv, true);
12712 }
12713
12714 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint64_t o) {
12715         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(o);
12716         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
12717         return ret_conv;
12718 }
12719
12720 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint64_t _res) {
12721         if (!ptr_is_owned(_res)) return;
12722         void* _res_ptr = untag_ptr(_res);
12723         CHECK_ACCESS(_res_ptr);
12724         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12725         FREE(untag_ptr(_res));
12726         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12727 }
12728
12729 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
12730         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12731         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
12732         return tag_ptr(ret_conv, true);
12733 }
12734 int64_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint64_t arg) {
12735         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(arg);
12736         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
12737         return ret_conv;
12738 }
12739
12740 uint64_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint64_t orig) {
12741         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(orig);
12742         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12743         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
12744         return tag_ptr(ret_conv, true);
12745 }
12746
12747 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint64_tArray _res) {
12748         LDKCVec_ChannelDetailsZ _res_constr;
12749         _res_constr.datalen = _res->arr_len;
12750         if (_res_constr.datalen > 0)
12751                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12752         else
12753                 _res_constr.data = NULL;
12754         uint64_t* _res_vals = _res->elems;
12755         for (size_t q = 0; q < _res_constr.datalen; q++) {
12756                 uint64_t _res_conv_16 = _res_vals[q];
12757                 LDKChannelDetails _res_conv_16_conv;
12758                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
12759                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
12760                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
12761                 _res_constr.data[q] = _res_conv_16_conv;
12762         }
12763         FREE(_res);
12764         CVec_ChannelDetailsZ_free(_res_constr);
12765 }
12766
12767 uint64_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint64_t o) {
12768         LDKRoute o_conv;
12769         o_conv.inner = untag_ptr(o);
12770         o_conv.is_owned = ptr_is_owned(o);
12771         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12772         o_conv = Route_clone(&o_conv);
12773         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12774         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
12775         return tag_ptr(ret_conv, true);
12776 }
12777
12778 uint64_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint64_t e) {
12779         LDKLightningError e_conv;
12780         e_conv.inner = untag_ptr(e);
12781         e_conv.is_owned = ptr_is_owned(e);
12782         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12783         e_conv = LightningError_clone(&e_conv);
12784         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12785         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
12786         return tag_ptr(ret_conv, true);
12787 }
12788
12789 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint64_t o) {
12790         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(o);
12791         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
12792         return ret_conv;
12793 }
12794
12795 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint64_t _res) {
12796         if (!ptr_is_owned(_res)) return;
12797         void* _res_ptr = untag_ptr(_res);
12798         CHECK_ACCESS(_res_ptr);
12799         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
12800         FREE(untag_ptr(_res));
12801         CResult_RouteLightningErrorZ_free(_res_conv);
12802 }
12803
12804 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
12805         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12806         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
12807         return tag_ptr(ret_conv, true);
12808 }
12809 int64_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint64_t arg) {
12810         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(arg);
12811         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
12812         return ret_conv;
12813 }
12814
12815 uint64_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint64_t orig) {
12816         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(orig);
12817         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12818         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12819         return tag_ptr(ret_conv, true);
12820 }
12821
12822 uint64_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_ok(uint64_t o) {
12823         void* o_ptr = untag_ptr(o);
12824         CHECK_ACCESS(o_ptr);
12825         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
12826         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(o));
12827         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12828         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
12829         return tag_ptr(ret_conv, true);
12830 }
12831
12832 uint64_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_err"))) TS_CResult_PaymentPurposeDecodeErrorZ_err(uint64_t e) {
12833         LDKDecodeError e_conv;
12834         e_conv.inner = untag_ptr(e);
12835         e_conv.is_owned = ptr_is_owned(e);
12836         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12837         e_conv = DecodeError_clone(&e_conv);
12838         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12839         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
12840         return tag_ptr(ret_conv, true);
12841 }
12842
12843 jboolean  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_is_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_is_ok(uint64_t o) {
12844         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(o);
12845         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
12846         return ret_conv;
12847 }
12848
12849 void  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_free"))) TS_CResult_PaymentPurposeDecodeErrorZ_free(uint64_t _res) {
12850         if (!ptr_is_owned(_res)) return;
12851         void* _res_ptr = untag_ptr(_res);
12852         CHECK_ACCESS(_res_ptr);
12853         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
12854         FREE(untag_ptr(_res));
12855         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
12856 }
12857
12858 static inline uint64_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
12859         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12860         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
12861         return tag_ptr(ret_conv, true);
12862 }
12863 int64_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentPurposeDecodeErrorZ_clone_ptr(uint64_t arg) {
12864         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(arg);
12865         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
12866         return ret_conv;
12867 }
12868
12869 uint64_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_clone"))) TS_CResult_PaymentPurposeDecodeErrorZ_clone(uint64_t orig) {
12870         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(orig);
12871         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12872         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
12873         return tag_ptr(ret_conv, true);
12874 }
12875
12876 uint64_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint64_t o) {
12877         void* o_ptr = untag_ptr(o);
12878         CHECK_ACCESS(o_ptr);
12879         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
12880         o_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(o));
12881         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12882         *ret_copy = COption_ClosureReasonZ_some(o_conv);
12883         uint64_t ret_ref = tag_ptr(ret_copy, true);
12884         return ret_ref;
12885 }
12886
12887 uint64_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
12888         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12889         *ret_copy = COption_ClosureReasonZ_none();
12890         uint64_t ret_ref = tag_ptr(ret_copy, true);
12891         return ret_ref;
12892 }
12893
12894 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint64_t _res) {
12895         if (!ptr_is_owned(_res)) return;
12896         void* _res_ptr = untag_ptr(_res);
12897         CHECK_ACCESS(_res_ptr);
12898         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
12899         FREE(untag_ptr(_res));
12900         COption_ClosureReasonZ_free(_res_conv);
12901 }
12902
12903 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12904         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12905         *ret_copy = COption_ClosureReasonZ_clone(arg);
12906         uint64_t ret_ref = tag_ptr(ret_copy, true);
12907         return ret_ref;
12908 }
12909 int64_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint64_t arg) {
12910         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(arg);
12911         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
12912         return ret_conv;
12913 }
12914
12915 uint64_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint64_t orig) {
12916         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(orig);
12917         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12918         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12919         uint64_t ret_ref = tag_ptr(ret_copy, true);
12920         return ret_ref;
12921 }
12922
12923 uint64_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint64_t o) {
12924         void* o_ptr = untag_ptr(o);
12925         CHECK_ACCESS(o_ptr);
12926         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12927         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)untag_ptr(o));
12928         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12929         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12930         return tag_ptr(ret_conv, true);
12931 }
12932
12933 uint64_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint64_t e) {
12934         LDKDecodeError e_conv;
12935         e_conv.inner = untag_ptr(e);
12936         e_conv.is_owned = ptr_is_owned(e);
12937         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12938         e_conv = DecodeError_clone(&e_conv);
12939         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12940         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12941         return tag_ptr(ret_conv, true);
12942 }
12943
12944 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint64_t o) {
12945         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(o);
12946         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12947         return ret_conv;
12948 }
12949
12950 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint64_t _res) {
12951         if (!ptr_is_owned(_res)) return;
12952         void* _res_ptr = untag_ptr(_res);
12953         CHECK_ACCESS(_res_ptr);
12954         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12955         FREE(untag_ptr(_res));
12956         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12957 }
12958
12959 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12960         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12961         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12962         return tag_ptr(ret_conv, true);
12963 }
12964 int64_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint64_t arg) {
12965         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(arg);
12966         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12967         return ret_conv;
12968 }
12969
12970 uint64_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint64_t orig) {
12971         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(orig);
12972         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12973         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12974         return tag_ptr(ret_conv, true);
12975 }
12976
12977 uint64_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_some"))) TS_COption_HTLCDestinationZ_some(uint64_t o) {
12978         void* o_ptr = untag_ptr(o);
12979         CHECK_ACCESS(o_ptr);
12980         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
12981         o_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(o));
12982         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
12983         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
12984         uint64_t ret_ref = tag_ptr(ret_copy, true);
12985         return ret_ref;
12986 }
12987
12988 uint64_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_none"))) TS_COption_HTLCDestinationZ_none() {
12989         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
12990         *ret_copy = COption_HTLCDestinationZ_none();
12991         uint64_t ret_ref = tag_ptr(ret_copy, true);
12992         return ret_ref;
12993 }
12994
12995 void  __attribute__((export_name("TS_COption_HTLCDestinationZ_free"))) TS_COption_HTLCDestinationZ_free(uint64_t _res) {
12996         if (!ptr_is_owned(_res)) return;
12997         void* _res_ptr = untag_ptr(_res);
12998         CHECK_ACCESS(_res_ptr);
12999         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
13000         FREE(untag_ptr(_res));
13001         COption_HTLCDestinationZ_free(_res_conv);
13002 }
13003
13004 static inline uint64_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
13005         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
13006         *ret_copy = COption_HTLCDestinationZ_clone(arg);
13007         uint64_t ret_ref = tag_ptr(ret_copy, true);
13008         return ret_ref;
13009 }
13010 int64_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_clone_ptr"))) TS_COption_HTLCDestinationZ_clone_ptr(uint64_t arg) {
13011         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(arg);
13012         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
13013         return ret_conv;
13014 }
13015
13016 uint64_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_clone"))) TS_COption_HTLCDestinationZ_clone(uint64_t orig) {
13017         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(orig);
13018         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
13019         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
13020         uint64_t ret_ref = tag_ptr(ret_copy, true);
13021         return ret_ref;
13022 }
13023
13024 uint64_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_ok"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_ok(uint64_t o) {
13025         void* o_ptr = untag_ptr(o);
13026         CHECK_ACCESS(o_ptr);
13027         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
13028         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)untag_ptr(o));
13029         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13030         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
13031         return tag_ptr(ret_conv, true);
13032 }
13033
13034 uint64_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_err"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_err(uint64_t e) {
13035         LDKDecodeError e_conv;
13036         e_conv.inner = untag_ptr(e);
13037         e_conv.is_owned = ptr_is_owned(e);
13038         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13039         e_conv = DecodeError_clone(&e_conv);
13040         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13041         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
13042         return tag_ptr(ret_conv, true);
13043 }
13044
13045 jboolean  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(uint64_t o) {
13046         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(o);
13047         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
13048         return ret_conv;
13049 }
13050
13051 void  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_free"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_free(uint64_t _res) {
13052         if (!ptr_is_owned(_res)) return;
13053         void* _res_ptr = untag_ptr(_res);
13054         CHECK_ACCESS(_res_ptr);
13055         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
13056         FREE(untag_ptr(_res));
13057         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
13058 }
13059
13060 static inline uint64_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
13061         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13062         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
13063         return tag_ptr(ret_conv, true);
13064 }
13065 int64_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(uint64_t arg) {
13066         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(arg);
13067         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
13068         return ret_conv;
13069 }
13070
13071 uint64_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone(uint64_t orig) {
13072         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(orig);
13073         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13074         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
13075         return tag_ptr(ret_conv, true);
13076 }
13077
13078 uint64_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint64_t o) {
13079         void* o_ptr = untag_ptr(o);
13080         CHECK_ACCESS(o_ptr);
13081         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
13082         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)untag_ptr(o));
13083         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13084         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
13085         uint64_t ret_ref = tag_ptr(ret_copy, true);
13086         return ret_ref;
13087 }
13088
13089 uint64_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
13090         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13091         *ret_copy = COption_NetworkUpdateZ_none();
13092         uint64_t ret_ref = tag_ptr(ret_copy, true);
13093         return ret_ref;
13094 }
13095
13096 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint64_t _res) {
13097         if (!ptr_is_owned(_res)) return;
13098         void* _res_ptr = untag_ptr(_res);
13099         CHECK_ACCESS(_res_ptr);
13100         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
13101         FREE(untag_ptr(_res));
13102         COption_NetworkUpdateZ_free(_res_conv);
13103 }
13104
13105 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
13106         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13107         *ret_copy = COption_NetworkUpdateZ_clone(arg);
13108         uint64_t ret_ref = tag_ptr(ret_copy, true);
13109         return ret_ref;
13110 }
13111 int64_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint64_t arg) {
13112         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(arg);
13113         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
13114         return ret_conv;
13115 }
13116
13117 uint64_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint64_t orig) {
13118         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(orig);
13119         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13120         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
13121         uint64_t ret_ref = tag_ptr(ret_copy, true);
13122         return ret_ref;
13123 }
13124
13125 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint64_tArray _res) {
13126         LDKCVec_SpendableOutputDescriptorZ _res_constr;
13127         _res_constr.datalen = _res->arr_len;
13128         if (_res_constr.datalen > 0)
13129                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
13130         else
13131                 _res_constr.data = NULL;
13132         uint64_t* _res_vals = _res->elems;
13133         for (size_t b = 0; b < _res_constr.datalen; b++) {
13134                 uint64_t _res_conv_27 = _res_vals[b];
13135                 void* _res_conv_27_ptr = untag_ptr(_res_conv_27);
13136                 CHECK_ACCESS(_res_conv_27_ptr);
13137                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
13138                 FREE(untag_ptr(_res_conv_27));
13139                 _res_constr.data[b] = _res_conv_27_conv;
13140         }
13141         FREE(_res);
13142         CVec_SpendableOutputDescriptorZ_free(_res_constr);
13143 }
13144
13145 uint64_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint64_t o) {
13146         void* o_ptr = untag_ptr(o);
13147         CHECK_ACCESS(o_ptr);
13148         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
13149         o_conv = Event_clone((LDKEvent*)untag_ptr(o));
13150         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13151         *ret_copy = COption_EventZ_some(o_conv);
13152         uint64_t ret_ref = tag_ptr(ret_copy, true);
13153         return ret_ref;
13154 }
13155
13156 uint64_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
13157         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13158         *ret_copy = COption_EventZ_none();
13159         uint64_t ret_ref = tag_ptr(ret_copy, true);
13160         return ret_ref;
13161 }
13162
13163 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint64_t _res) {
13164         if (!ptr_is_owned(_res)) return;
13165         void* _res_ptr = untag_ptr(_res);
13166         CHECK_ACCESS(_res_ptr);
13167         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
13168         FREE(untag_ptr(_res));
13169         COption_EventZ_free(_res_conv);
13170 }
13171
13172 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
13173         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13174         *ret_copy = COption_EventZ_clone(arg);
13175         uint64_t ret_ref = tag_ptr(ret_copy, true);
13176         return ret_ref;
13177 }
13178 int64_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint64_t arg) {
13179         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)untag_ptr(arg);
13180         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
13181         return ret_conv;
13182 }
13183
13184 uint64_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint64_t orig) {
13185         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)untag_ptr(orig);
13186         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13187         *ret_copy = COption_EventZ_clone(orig_conv);
13188         uint64_t ret_ref = tag_ptr(ret_copy, true);
13189         return ret_ref;
13190 }
13191
13192 uint64_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint64_t o) {
13193         void* o_ptr = untag_ptr(o);
13194         CHECK_ACCESS(o_ptr);
13195         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
13196         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)untag_ptr(o));
13197         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13198         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
13199         return tag_ptr(ret_conv, true);
13200 }
13201
13202 uint64_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint64_t e) {
13203         LDKDecodeError e_conv;
13204         e_conv.inner = untag_ptr(e);
13205         e_conv.is_owned = ptr_is_owned(e);
13206         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13207         e_conv = DecodeError_clone(&e_conv);
13208         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13209         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
13210         return tag_ptr(ret_conv, true);
13211 }
13212
13213 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint64_t o) {
13214         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(o);
13215         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
13216         return ret_conv;
13217 }
13218
13219 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint64_t _res) {
13220         if (!ptr_is_owned(_res)) return;
13221         void* _res_ptr = untag_ptr(_res);
13222         CHECK_ACCESS(_res_ptr);
13223         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
13224         FREE(untag_ptr(_res));
13225         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
13226 }
13227
13228 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
13229         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13230         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
13231         return tag_ptr(ret_conv, true);
13232 }
13233 int64_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint64_t arg) {
13234         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(arg);
13235         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
13236         return ret_conv;
13237 }
13238
13239 uint64_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint64_t orig) {
13240         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(orig);
13241         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13242         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
13243         return tag_ptr(ret_conv, true);
13244 }
13245
13246 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint64_tArray _res) {
13247         LDKCVec_MessageSendEventZ _res_constr;
13248         _res_constr.datalen = _res->arr_len;
13249         if (_res_constr.datalen > 0)
13250                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
13251         else
13252                 _res_constr.data = NULL;
13253         uint64_t* _res_vals = _res->elems;
13254         for (size_t s = 0; s < _res_constr.datalen; s++) {
13255                 uint64_t _res_conv_18 = _res_vals[s];
13256                 void* _res_conv_18_ptr = untag_ptr(_res_conv_18);
13257                 CHECK_ACCESS(_res_conv_18_ptr);
13258                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
13259                 FREE(untag_ptr(_res_conv_18));
13260                 _res_constr.data[s] = _res_conv_18_conv;
13261         }
13262         FREE(_res);
13263         CVec_MessageSendEventZ_free(_res_constr);
13264 }
13265
13266 uint64_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint64_t o) {
13267         void* o_ptr = untag_ptr(o);
13268         CHECK_ACCESS(o_ptr);
13269         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
13270         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
13271         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13272         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
13273         return tag_ptr(ret_conv, true);
13274 }
13275
13276 uint64_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
13277         LDKAccessError e_conv = LDKAccessError_from_js(e);
13278         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13279         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
13280         return tag_ptr(ret_conv, true);
13281 }
13282
13283 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint64_t o) {
13284         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(o);
13285         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
13286         return ret_conv;
13287 }
13288
13289 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint64_t _res) {
13290         if (!ptr_is_owned(_res)) return;
13291         void* _res_ptr = untag_ptr(_res);
13292         CHECK_ACCESS(_res_ptr);
13293         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
13294         FREE(untag_ptr(_res));
13295         CResult_TxOutAccessErrorZ_free(_res_conv);
13296 }
13297
13298 static inline uint64_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
13299         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13300         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
13301         return tag_ptr(ret_conv, true);
13302 }
13303 int64_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint64_t arg) {
13304         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(arg);
13305         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
13306         return ret_conv;
13307 }
13308
13309 uint64_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint64_t orig) {
13310         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(orig);
13311         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13312         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
13313         return tag_ptr(ret_conv, true);
13314 }
13315
13316 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
13317         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13318         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
13319         return tag_ptr(ret_conv, true);
13320 }
13321 int64_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint64_t arg) {
13322         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(arg);
13323         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
13324         return ret_conv;
13325 }
13326
13327 uint64_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint64_t orig) {
13328         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(orig);
13329         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13330         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
13331         return tag_ptr(ret_conv, true);
13332 }
13333
13334 uint64_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(uint32_t a, int8_tArray b) {
13335         LDKTransaction b_ref;
13336         b_ref.datalen = b->arr_len;
13337         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
13338         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
13339         b_ref.data_is_owned = true;
13340         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13341         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
13342         return tag_ptr(ret_conv, true);
13343 }
13344
13345 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint64_t _res) {
13346         if (!ptr_is_owned(_res)) return;
13347         void* _res_ptr = untag_ptr(_res);
13348         CHECK_ACCESS(_res_ptr);
13349         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
13350         FREE(untag_ptr(_res));
13351         C2Tuple_usizeTransactionZ_free(_res_conv);
13352 }
13353
13354 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint64_tArray _res) {
13355         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
13356         _res_constr.datalen = _res->arr_len;
13357         if (_res_constr.datalen > 0)
13358                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
13359         else
13360                 _res_constr.data = NULL;
13361         uint64_t* _res_vals = _res->elems;
13362         for (size_t c = 0; c < _res_constr.datalen; c++) {
13363                 uint64_t _res_conv_28 = _res_vals[c];
13364                 void* _res_conv_28_ptr = untag_ptr(_res_conv_28);
13365                 CHECK_ACCESS(_res_conv_28_ptr);
13366                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
13367                 FREE(untag_ptr(_res_conv_28));
13368                 _res_constr.data[c] = _res_conv_28_conv;
13369         }
13370         FREE(_res);
13371         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
13372 }
13373
13374 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
13375         LDKCVec_TxidZ _res_constr;
13376         _res_constr.datalen = _res->arr_len;
13377         if (_res_constr.datalen > 0)
13378                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
13379         else
13380                 _res_constr.data = NULL;
13381         int8_tArray* _res_vals = (void*) _res->elems;
13382         for (size_t m = 0; m < _res_constr.datalen; m++) {
13383                 int8_tArray _res_conv_12 = _res_vals[m];
13384                 LDKThirtyTwoBytes _res_conv_12_ref;
13385                 CHECK(_res_conv_12->arr_len == 32);
13386                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
13387                 _res_constr.data[m] = _res_conv_12_ref;
13388         }
13389         FREE(_res);
13390         CVec_TxidZ_free(_res_constr);
13391 }
13392
13393 uint64_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
13394         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13395         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
13396         return tag_ptr(ret_conv, true);
13397 }
13398
13399 uint64_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
13400         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
13401         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13402         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
13403         return tag_ptr(ret_conv, true);
13404 }
13405
13406 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint64_t o) {
13407         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(o);
13408         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
13409         return ret_conv;
13410 }
13411
13412 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint64_t _res) {
13413         if (!ptr_is_owned(_res)) return;
13414         void* _res_ptr = untag_ptr(_res);
13415         CHECK_ACCESS(_res_ptr);
13416         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
13417         FREE(untag_ptr(_res));
13418         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
13419 }
13420
13421 static inline uint64_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
13422         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13423         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
13424         return tag_ptr(ret_conv, true);
13425 }
13426 int64_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint64_t arg) {
13427         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(arg);
13428         int64_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
13429         return ret_conv;
13430 }
13431
13432 uint64_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint64_t orig) {
13433         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(orig);
13434         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13435         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
13436         return tag_ptr(ret_conv, true);
13437 }
13438
13439 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint64_tArray _res) {
13440         LDKCVec_MonitorEventZ _res_constr;
13441         _res_constr.datalen = _res->arr_len;
13442         if (_res_constr.datalen > 0)
13443                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13444         else
13445                 _res_constr.data = NULL;
13446         uint64_t* _res_vals = _res->elems;
13447         for (size_t o = 0; o < _res_constr.datalen; o++) {
13448                 uint64_t _res_conv_14 = _res_vals[o];
13449                 void* _res_conv_14_ptr = untag_ptr(_res_conv_14);
13450                 CHECK_ACCESS(_res_conv_14_ptr);
13451                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
13452                 FREE(untag_ptr(_res_conv_14));
13453                 _res_constr.data[o] = _res_conv_14_conv;
13454         }
13455         FREE(_res);
13456         CVec_MonitorEventZ_free(_res_constr);
13457 }
13458
13459 static inline uint64_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
13460         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
13461         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
13462         return tag_ptr(ret_conv, true);
13463 }
13464 int64_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(uint64_t arg) {
13465         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(arg);
13466         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
13467         return ret_conv;
13468 }
13469
13470 uint64_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(uint64_t orig) {
13471         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(orig);
13472         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
13473         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
13474         return tag_ptr(ret_conv, true);
13475 }
13476
13477 uint64_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(uint64_t a, uint64_tArray b, int8_tArray c) {
13478         LDKOutPoint a_conv;
13479         a_conv.inner = untag_ptr(a);
13480         a_conv.is_owned = ptr_is_owned(a);
13481         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
13482         a_conv = OutPoint_clone(&a_conv);
13483         LDKCVec_MonitorEventZ b_constr;
13484         b_constr.datalen = b->arr_len;
13485         if (b_constr.datalen > 0)
13486                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13487         else
13488                 b_constr.data = NULL;
13489         uint64_t* b_vals = b->elems;
13490         for (size_t o = 0; o < b_constr.datalen; o++) {
13491                 uint64_t b_conv_14 = b_vals[o];
13492                 void* b_conv_14_ptr = untag_ptr(b_conv_14);
13493                 CHECK_ACCESS(b_conv_14_ptr);
13494                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
13495                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(b_conv_14));
13496                 b_constr.data[o] = b_conv_14_conv;
13497         }
13498         FREE(b);
13499         LDKPublicKey c_ref;
13500         CHECK(c->arr_len == 33);
13501         memcpy(c_ref.compressed_form, c->elems, 33); FREE(c);
13502         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
13503         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
13504         return tag_ptr(ret_conv, true);
13505 }
13506
13507 void  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(uint64_t _res) {
13508         if (!ptr_is_owned(_res)) return;
13509         void* _res_ptr = untag_ptr(_res);
13510         CHECK_ACCESS(_res_ptr);
13511         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
13512         FREE(untag_ptr(_res));
13513         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
13514 }
13515
13516 void  __attribute__((export_name("TS_CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free"))) TS_CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(uint64_tArray _res) {
13517         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
13518         _res_constr.datalen = _res->arr_len;
13519         if (_res_constr.datalen > 0)
13520                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
13521         else
13522                 _res_constr.data = NULL;
13523         uint64_t* _res_vals = _res->elems;
13524         for (size_t x = 0; x < _res_constr.datalen; x++) {
13525                 uint64_t _res_conv_49 = _res_vals[x];
13526                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
13527                 CHECK_ACCESS(_res_conv_49_ptr);
13528                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
13529                 FREE(untag_ptr(_res_conv_49));
13530                 _res_constr.data[x] = _res_conv_49_conv;
13531         }
13532         FREE(_res);
13533         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
13534 }
13535
13536 uint64_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok(uint64_t o) {
13537         LDKFixedPenaltyScorer o_conv;
13538         o_conv.inner = untag_ptr(o);
13539         o_conv.is_owned = ptr_is_owned(o);
13540         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13541         o_conv = FixedPenaltyScorer_clone(&o_conv);
13542         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13543         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
13544         return tag_ptr(ret_conv, true);
13545 }
13546
13547 uint64_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_err(uint64_t e) {
13548         LDKDecodeError e_conv;
13549         e_conv.inner = untag_ptr(e);
13550         e_conv.is_owned = ptr_is_owned(e);
13551         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13552         e_conv = DecodeError_clone(&e_conv);
13553         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13554         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
13555         return tag_ptr(ret_conv, true);
13556 }
13557
13558 jboolean  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(uint64_t o) {
13559         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(o);
13560         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
13561         return ret_conv;
13562 }
13563
13564 void  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_free"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_free(uint64_t _res) {
13565         if (!ptr_is_owned(_res)) return;
13566         void* _res_ptr = untag_ptr(_res);
13567         CHECK_ACCESS(_res_ptr);
13568         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
13569         FREE(untag_ptr(_res));
13570         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
13571 }
13572
13573 static inline uint64_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
13574         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13575         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
13576         return tag_ptr(ret_conv, true);
13577 }
13578 int64_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(uint64_t arg) {
13579         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(arg);
13580         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
13581         return ret_conv;
13582 }
13583
13584 uint64_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone(uint64_t orig) {
13585         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(orig);
13586         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13587         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
13588         return tag_ptr(ret_conv, true);
13589 }
13590
13591 static inline uint64_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
13592         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13593         *ret_conv = C2Tuple_u64u64Z_clone(arg);
13594         return tag_ptr(ret_conv, true);
13595 }
13596 int64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_clone_ptr"))) TS_C2Tuple_u64u64Z_clone_ptr(uint64_t arg) {
13597         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(arg);
13598         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
13599         return ret_conv;
13600 }
13601
13602 uint64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_clone"))) TS_C2Tuple_u64u64Z_clone(uint64_t orig) {
13603         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(orig);
13604         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13605         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
13606         return tag_ptr(ret_conv, true);
13607 }
13608
13609 uint64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_new"))) TS_C2Tuple_u64u64Z_new(int64_t a, int64_t b) {
13610         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13611         *ret_conv = C2Tuple_u64u64Z_new(a, b);
13612         return tag_ptr(ret_conv, true);
13613 }
13614
13615 void  __attribute__((export_name("TS_C2Tuple_u64u64Z_free"))) TS_C2Tuple_u64u64Z_free(uint64_t _res) {
13616         if (!ptr_is_owned(_res)) return;
13617         void* _res_ptr = untag_ptr(_res);
13618         CHECK_ACCESS(_res_ptr);
13619         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
13620         FREE(untag_ptr(_res));
13621         C2Tuple_u64u64Z_free(_res_conv);
13622 }
13623
13624 uint64_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_some"))) TS_COption_C2Tuple_u64u64ZZ_some(uint64_t o) {
13625         void* o_ptr = untag_ptr(o);
13626         CHECK_ACCESS(o_ptr);
13627         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
13628         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)untag_ptr(o));
13629         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13630         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
13631         uint64_t ret_ref = tag_ptr(ret_copy, true);
13632         return ret_ref;
13633 }
13634
13635 uint64_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_none"))) TS_COption_C2Tuple_u64u64ZZ_none() {
13636         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13637         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
13638         uint64_t ret_ref = tag_ptr(ret_copy, true);
13639         return ret_ref;
13640 }
13641
13642 void  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_free"))) TS_COption_C2Tuple_u64u64ZZ_free(uint64_t _res) {
13643         if (!ptr_is_owned(_res)) return;
13644         void* _res_ptr = untag_ptr(_res);
13645         CHECK_ACCESS(_res_ptr);
13646         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
13647         FREE(untag_ptr(_res));
13648         COption_C2Tuple_u64u64ZZ_free(_res_conv);
13649 }
13650
13651 static inline uint64_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
13652         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13653         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
13654         uint64_t ret_ref = tag_ptr(ret_copy, true);
13655         return ret_ref;
13656 }
13657 int64_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_clone_ptr"))) TS_COption_C2Tuple_u64u64ZZ_clone_ptr(uint64_t arg) {
13658         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(arg);
13659         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
13660         return ret_conv;
13661 }
13662
13663 uint64_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_clone"))) TS_COption_C2Tuple_u64u64ZZ_clone(uint64_t orig) {
13664         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(orig);
13665         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13666         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
13667         uint64_t ret_ref = tag_ptr(ret_copy, true);
13668         return ret_ref;
13669 }
13670
13671 void  __attribute__((export_name("TS_CVec_NodeIdZ_free"))) TS_CVec_NodeIdZ_free(uint64_tArray _res) {
13672         LDKCVec_NodeIdZ _res_constr;
13673         _res_constr.datalen = _res->arr_len;
13674         if (_res_constr.datalen > 0)
13675                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
13676         else
13677                 _res_constr.data = NULL;
13678         uint64_t* _res_vals = _res->elems;
13679         for (size_t i = 0; i < _res_constr.datalen; i++) {
13680                 uint64_t _res_conv_8 = _res_vals[i];
13681                 LDKNodeId _res_conv_8_conv;
13682                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
13683                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
13684                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
13685                 _res_constr.data[i] = _res_conv_8_conv;
13686         }
13687         FREE(_res);
13688         CVec_NodeIdZ_free(_res_constr);
13689 }
13690
13691 uint64_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_ok(uint64_t o) {
13692         LDKProbabilisticScorer o_conv;
13693         o_conv.inner = untag_ptr(o);
13694         o_conv.is_owned = ptr_is_owned(o);
13695         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13696         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
13697         
13698         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
13699         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
13700         return tag_ptr(ret_conv, true);
13701 }
13702
13703 uint64_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_err(uint64_t e) {
13704         LDKDecodeError e_conv;
13705         e_conv.inner = untag_ptr(e);
13706         e_conv.is_owned = ptr_is_owned(e);
13707         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13708         e_conv = DecodeError_clone(&e_conv);
13709         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
13710         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
13711         return tag_ptr(ret_conv, true);
13712 }
13713
13714 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok(uint64_t o) {
13715         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(o);
13716         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
13717         return ret_conv;
13718 }
13719
13720 void  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_free"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_free(uint64_t _res) {
13721         if (!ptr_is_owned(_res)) return;
13722         void* _res_ptr = untag_ptr(_res);
13723         CHECK_ACCESS(_res_ptr);
13724         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
13725         FREE(untag_ptr(_res));
13726         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
13727 }
13728
13729 uint64_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint64_t o) {
13730         LDKInitFeatures o_conv;
13731         o_conv.inner = untag_ptr(o);
13732         o_conv.is_owned = ptr_is_owned(o);
13733         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13734         o_conv = InitFeatures_clone(&o_conv);
13735         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13736         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
13737         return tag_ptr(ret_conv, true);
13738 }
13739
13740 uint64_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint64_t e) {
13741         LDKDecodeError e_conv;
13742         e_conv.inner = untag_ptr(e);
13743         e_conv.is_owned = ptr_is_owned(e);
13744         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13745         e_conv = DecodeError_clone(&e_conv);
13746         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13747         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
13748         return tag_ptr(ret_conv, true);
13749 }
13750
13751 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint64_t o) {
13752         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(o);
13753         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
13754         return ret_conv;
13755 }
13756
13757 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint64_t _res) {
13758         if (!ptr_is_owned(_res)) return;
13759         void* _res_ptr = untag_ptr(_res);
13760         CHECK_ACCESS(_res_ptr);
13761         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
13762         FREE(untag_ptr(_res));
13763         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
13764 }
13765
13766 static inline uint64_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13767         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13768         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
13769         return tag_ptr(ret_conv, true);
13770 }
13771 int64_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_InitFeaturesDecodeErrorZ_clone_ptr(uint64_t arg) {
13772         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(arg);
13773         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13774         return ret_conv;
13775 }
13776
13777 uint64_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_clone"))) TS_CResult_InitFeaturesDecodeErrorZ_clone(uint64_t orig) {
13778         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(orig);
13779         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13780         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
13781         return tag_ptr(ret_conv, true);
13782 }
13783
13784 uint64_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint64_t o) {
13785         LDKChannelFeatures o_conv;
13786         o_conv.inner = untag_ptr(o);
13787         o_conv.is_owned = ptr_is_owned(o);
13788         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13789         o_conv = ChannelFeatures_clone(&o_conv);
13790         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13791         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
13792         return tag_ptr(ret_conv, true);
13793 }
13794
13795 uint64_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint64_t e) {
13796         LDKDecodeError e_conv;
13797         e_conv.inner = untag_ptr(e);
13798         e_conv.is_owned = ptr_is_owned(e);
13799         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13800         e_conv = DecodeError_clone(&e_conv);
13801         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13802         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
13803         return tag_ptr(ret_conv, true);
13804 }
13805
13806 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint64_t o) {
13807         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(o);
13808         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
13809         return ret_conv;
13810 }
13811
13812 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint64_t _res) {
13813         if (!ptr_is_owned(_res)) return;
13814         void* _res_ptr = untag_ptr(_res);
13815         CHECK_ACCESS(_res_ptr);
13816         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
13817         FREE(untag_ptr(_res));
13818         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
13819 }
13820
13821 static inline uint64_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13822         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13823         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
13824         return tag_ptr(ret_conv, true);
13825 }
13826 int64_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(uint64_t arg) {
13827         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(arg);
13828         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13829         return ret_conv;
13830 }
13831
13832 uint64_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_clone"))) TS_CResult_ChannelFeaturesDecodeErrorZ_clone(uint64_t orig) {
13833         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(orig);
13834         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13835         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
13836         return tag_ptr(ret_conv, true);
13837 }
13838
13839 uint64_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint64_t o) {
13840         LDKNodeFeatures o_conv;
13841         o_conv.inner = untag_ptr(o);
13842         o_conv.is_owned = ptr_is_owned(o);
13843         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13844         o_conv = NodeFeatures_clone(&o_conv);
13845         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13846         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
13847         return tag_ptr(ret_conv, true);
13848 }
13849
13850 uint64_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint64_t e) {
13851         LDKDecodeError e_conv;
13852         e_conv.inner = untag_ptr(e);
13853         e_conv.is_owned = ptr_is_owned(e);
13854         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13855         e_conv = DecodeError_clone(&e_conv);
13856         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13857         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
13858         return tag_ptr(ret_conv, true);
13859 }
13860
13861 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint64_t o) {
13862         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(o);
13863         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
13864         return ret_conv;
13865 }
13866
13867 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint64_t _res) {
13868         if (!ptr_is_owned(_res)) return;
13869         void* _res_ptr = untag_ptr(_res);
13870         CHECK_ACCESS(_res_ptr);
13871         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
13872         FREE(untag_ptr(_res));
13873         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
13874 }
13875
13876 static inline uint64_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13877         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13878         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
13879         return tag_ptr(ret_conv, true);
13880 }
13881 int64_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_NodeFeaturesDecodeErrorZ_clone_ptr(uint64_t arg) {
13882         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(arg);
13883         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13884         return ret_conv;
13885 }
13886
13887 uint64_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_clone"))) TS_CResult_NodeFeaturesDecodeErrorZ_clone(uint64_t orig) {
13888         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(orig);
13889         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13890         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
13891         return tag_ptr(ret_conv, true);
13892 }
13893
13894 uint64_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint64_t o) {
13895         LDKInvoiceFeatures o_conv;
13896         o_conv.inner = untag_ptr(o);
13897         o_conv.is_owned = ptr_is_owned(o);
13898         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13899         o_conv = InvoiceFeatures_clone(&o_conv);
13900         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13901         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
13902         return tag_ptr(ret_conv, true);
13903 }
13904
13905 uint64_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint64_t e) {
13906         LDKDecodeError e_conv;
13907         e_conv.inner = untag_ptr(e);
13908         e_conv.is_owned = ptr_is_owned(e);
13909         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13910         e_conv = DecodeError_clone(&e_conv);
13911         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13912         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
13913         return tag_ptr(ret_conv, true);
13914 }
13915
13916 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint64_t o) {
13917         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(o);
13918         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
13919         return ret_conv;
13920 }
13921
13922 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint64_t _res) {
13923         if (!ptr_is_owned(_res)) return;
13924         void* _res_ptr = untag_ptr(_res);
13925         CHECK_ACCESS(_res_ptr);
13926         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
13927         FREE(untag_ptr(_res));
13928         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
13929 }
13930
13931 static inline uint64_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13932         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13933         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
13934         return tag_ptr(ret_conv, true);
13935 }
13936 int64_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(uint64_t arg) {
13937         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(arg);
13938         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13939         return ret_conv;
13940 }
13941
13942 uint64_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_clone"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_clone(uint64_t orig) {
13943         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(orig);
13944         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13945         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
13946         return tag_ptr(ret_conv, true);
13947 }
13948
13949 uint64_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint64_t o) {
13950         LDKChannelTypeFeatures o_conv;
13951         o_conv.inner = untag_ptr(o);
13952         o_conv.is_owned = ptr_is_owned(o);
13953         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13954         o_conv = ChannelTypeFeatures_clone(&o_conv);
13955         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13956         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
13957         return tag_ptr(ret_conv, true);
13958 }
13959
13960 uint64_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint64_t e) {
13961         LDKDecodeError e_conv;
13962         e_conv.inner = untag_ptr(e);
13963         e_conv.is_owned = ptr_is_owned(e);
13964         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13965         e_conv = DecodeError_clone(&e_conv);
13966         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13967         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
13968         return tag_ptr(ret_conv, true);
13969 }
13970
13971 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint64_t o) {
13972         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(o);
13973         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
13974         return ret_conv;
13975 }
13976
13977 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint64_t _res) {
13978         if (!ptr_is_owned(_res)) return;
13979         void* _res_ptr = untag_ptr(_res);
13980         CHECK_ACCESS(_res_ptr);
13981         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
13982         FREE(untag_ptr(_res));
13983         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
13984 }
13985
13986 static inline uint64_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13987         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13988         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
13989         return tag_ptr(ret_conv, true);
13990 }
13991 int64_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(uint64_t arg) {
13992         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(arg);
13993         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13994         return ret_conv;
13995 }
13996
13997 uint64_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone(uint64_t orig) {
13998         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(orig);
13999         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
14000         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
14001         return tag_ptr(ret_conv, true);
14002 }
14003
14004 uint64_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint64_t o) {
14005         LDKNodeId o_conv;
14006         o_conv.inner = untag_ptr(o);
14007         o_conv.is_owned = ptr_is_owned(o);
14008         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14009         o_conv = NodeId_clone(&o_conv);
14010         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14011         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
14012         return tag_ptr(ret_conv, true);
14013 }
14014
14015 uint64_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint64_t e) {
14016         LDKDecodeError e_conv;
14017         e_conv.inner = untag_ptr(e);
14018         e_conv.is_owned = ptr_is_owned(e);
14019         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14020         e_conv = DecodeError_clone(&e_conv);
14021         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14022         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
14023         return tag_ptr(ret_conv, true);
14024 }
14025
14026 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint64_t o) {
14027         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(o);
14028         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
14029         return ret_conv;
14030 }
14031
14032 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint64_t _res) {
14033         if (!ptr_is_owned(_res)) return;
14034         void* _res_ptr = untag_ptr(_res);
14035         CHECK_ACCESS(_res_ptr);
14036         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
14037         FREE(untag_ptr(_res));
14038         CResult_NodeIdDecodeErrorZ_free(_res_conv);
14039 }
14040
14041 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
14042         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14043         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
14044         return tag_ptr(ret_conv, true);
14045 }
14046 int64_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint64_t arg) {
14047         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(arg);
14048         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
14049         return ret_conv;
14050 }
14051
14052 uint64_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint64_t orig) {
14053         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(orig);
14054         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14055         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
14056         return tag_ptr(ret_conv, true);
14057 }
14058
14059 uint64_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint64_t o) {
14060         void* o_ptr = untag_ptr(o);
14061         CHECK_ACCESS(o_ptr);
14062         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
14063         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(o));
14064         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14065         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
14066         return tag_ptr(ret_conv, true);
14067 }
14068
14069 uint64_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint64_t e) {
14070         LDKDecodeError e_conv;
14071         e_conv.inner = untag_ptr(e);
14072         e_conv.is_owned = ptr_is_owned(e);
14073         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14074         e_conv = DecodeError_clone(&e_conv);
14075         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14076         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
14077         return tag_ptr(ret_conv, true);
14078 }
14079
14080 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint64_t o) {
14081         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(o);
14082         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
14083         return ret_conv;
14084 }
14085
14086 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint64_t _res) {
14087         if (!ptr_is_owned(_res)) return;
14088         void* _res_ptr = untag_ptr(_res);
14089         CHECK_ACCESS(_res_ptr);
14090         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
14091         FREE(untag_ptr(_res));
14092         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
14093 }
14094
14095 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
14096         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14097         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
14098         return tag_ptr(ret_conv, true);
14099 }
14100 int64_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint64_t arg) {
14101         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(arg);
14102         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
14103         return ret_conv;
14104 }
14105
14106 uint64_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint64_t orig) {
14107         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(orig);
14108         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14109         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
14110         return tag_ptr(ret_conv, true);
14111 }
14112
14113 uint64_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint64_t o) {
14114         void* o_ptr = untag_ptr(o);
14115         CHECK_ACCESS(o_ptr);
14116         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
14117         if (o_conv.free == LDKAccess_JCalls_free) {
14118                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14119                 LDKAccess_JCalls_cloned(&o_conv);
14120         }
14121         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
14122         *ret_copy = COption_AccessZ_some(o_conv);
14123         uint64_t ret_ref = tag_ptr(ret_copy, true);
14124         return ret_ref;
14125 }
14126
14127 uint64_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
14128         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
14129         *ret_copy = COption_AccessZ_none();
14130         uint64_t ret_ref = tag_ptr(ret_copy, true);
14131         return ret_ref;
14132 }
14133
14134 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint64_t _res) {
14135         if (!ptr_is_owned(_res)) return;
14136         void* _res_ptr = untag_ptr(_res);
14137         CHECK_ACCESS(_res_ptr);
14138         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
14139         FREE(untag_ptr(_res));
14140         COption_AccessZ_free(_res_conv);
14141 }
14142
14143 uint64_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
14144         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14145         *ret_conv = CResult_boolLightningErrorZ_ok(o);
14146         return tag_ptr(ret_conv, true);
14147 }
14148
14149 uint64_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint64_t e) {
14150         LDKLightningError e_conv;
14151         e_conv.inner = untag_ptr(e);
14152         e_conv.is_owned = ptr_is_owned(e);
14153         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14154         e_conv = LightningError_clone(&e_conv);
14155         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14156         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
14157         return tag_ptr(ret_conv, true);
14158 }
14159
14160 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint64_t o) {
14161         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(o);
14162         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
14163         return ret_conv;
14164 }
14165
14166 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint64_t _res) {
14167         if (!ptr_is_owned(_res)) return;
14168         void* _res_ptr = untag_ptr(_res);
14169         CHECK_ACCESS(_res_ptr);
14170         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
14171         FREE(untag_ptr(_res));
14172         CResult_boolLightningErrorZ_free(_res_conv);
14173 }
14174
14175 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
14176         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14177         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
14178         return tag_ptr(ret_conv, true);
14179 }
14180 int64_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint64_t arg) {
14181         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(arg);
14182         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
14183         return ret_conv;
14184 }
14185
14186 uint64_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint64_t orig) {
14187         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(orig);
14188         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14189         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
14190         return tag_ptr(ret_conv, true);
14191 }
14192
14193 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
14194         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
14195         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
14196         return tag_ptr(ret_conv, true);
14197 }
14198 int64_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint64_t arg) {
14199         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(arg);
14200         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
14201         return ret_conv;
14202 }
14203
14204 uint64_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint64_t orig) {
14205         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(orig);
14206         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
14207         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
14208         return tag_ptr(ret_conv, true);
14209 }
14210
14211 uint64_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint64_t a, uint64_t b, uint64_t c) {
14212         LDKChannelAnnouncement a_conv;
14213         a_conv.inner = untag_ptr(a);
14214         a_conv.is_owned = ptr_is_owned(a);
14215         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
14216         a_conv = ChannelAnnouncement_clone(&a_conv);
14217         LDKChannelUpdate b_conv;
14218         b_conv.inner = untag_ptr(b);
14219         b_conv.is_owned = ptr_is_owned(b);
14220         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
14221         b_conv = ChannelUpdate_clone(&b_conv);
14222         LDKChannelUpdate c_conv;
14223         c_conv.inner = untag_ptr(c);
14224         c_conv.is_owned = ptr_is_owned(c);
14225         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
14226         c_conv = ChannelUpdate_clone(&c_conv);
14227         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
14228         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
14229         return tag_ptr(ret_conv, true);
14230 }
14231
14232 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint64_t _res) {
14233         if (!ptr_is_owned(_res)) return;
14234         void* _res_ptr = untag_ptr(_res);
14235         CHECK_ACCESS(_res_ptr);
14236         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
14237         FREE(untag_ptr(_res));
14238         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
14239 }
14240
14241 uint64_t  __attribute__((export_name("TS_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some"))) TS_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(uint64_t o) {
14242         void* o_ptr = untag_ptr(o);
14243         CHECK_ACCESS(o_ptr);
14244         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(o_ptr);
14245         o_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(o));
14246         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
14247         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(o_conv);
14248         uint64_t ret_ref = tag_ptr(ret_copy, true);
14249         return ret_ref;
14250 }
14251
14252 uint64_t  __attribute__((export_name("TS_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none"))) TS_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none() {
14253         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
14254         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none();
14255         uint64_t ret_ref = tag_ptr(ret_copy, true);
14256         return ret_ref;
14257 }
14258
14259 void  __attribute__((export_name("TS_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint64_t _res) {
14260         if (!ptr_is_owned(_res)) return;
14261         void* _res_ptr = untag_ptr(_res);
14262         CHECK_ACCESS(_res_ptr);
14263         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(_res_ptr);
14264         FREE(untag_ptr(_res));
14265         COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_conv);
14266 }
14267
14268 static inline uint64_t COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR arg) {
14269         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
14270         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(arg);
14271         uint64_t ret_ref = tag_ptr(ret_copy, true);
14272         return ret_ref;
14273 }
14274 int64_t  __attribute__((export_name("TS_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr"))) TS_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(uint64_t arg) {
14275         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* arg_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(arg);
14276         int64_t ret_conv = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(arg_conv);
14277         return ret_conv;
14278 }
14279
14280 uint64_t  __attribute__((export_name("TS_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone"))) TS_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(uint64_t orig) {
14281         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* orig_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(orig);
14282         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
14283         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig_conv);
14284         uint64_t ret_ref = tag_ptr(ret_copy, true);
14285         return ret_ref;
14286 }
14287
14288 uint64_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
14289         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14290         *ret_conv = CResult_NoneLightningErrorZ_ok();
14291         return tag_ptr(ret_conv, true);
14292 }
14293
14294 uint64_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint64_t e) {
14295         LDKLightningError e_conv;
14296         e_conv.inner = untag_ptr(e);
14297         e_conv.is_owned = ptr_is_owned(e);
14298         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14299         e_conv = LightningError_clone(&e_conv);
14300         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14301         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
14302         return tag_ptr(ret_conv, true);
14303 }
14304
14305 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint64_t o) {
14306         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(o);
14307         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
14308         return ret_conv;
14309 }
14310
14311 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint64_t _res) {
14312         if (!ptr_is_owned(_res)) return;
14313         void* _res_ptr = untag_ptr(_res);
14314         CHECK_ACCESS(_res_ptr);
14315         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
14316         FREE(untag_ptr(_res));
14317         CResult_NoneLightningErrorZ_free(_res_conv);
14318 }
14319
14320 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
14321         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14322         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
14323         return tag_ptr(ret_conv, true);
14324 }
14325 int64_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint64_t arg) {
14326         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(arg);
14327         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
14328         return ret_conv;
14329 }
14330
14331 uint64_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint64_t orig) {
14332         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(orig);
14333         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14334         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
14335         return tag_ptr(ret_conv, true);
14336 }
14337
14338 uint64_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok(uint64_t o) {
14339         LDKChannelUpdateInfo o_conv;
14340         o_conv.inner = untag_ptr(o);
14341         o_conv.is_owned = ptr_is_owned(o);
14342         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14343         o_conv = ChannelUpdateInfo_clone(&o_conv);
14344         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14345         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
14346         return tag_ptr(ret_conv, true);
14347 }
14348
14349 uint64_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_err(uint64_t e) {
14350         LDKDecodeError e_conv;
14351         e_conv.inner = untag_ptr(e);
14352         e_conv.is_owned = ptr_is_owned(e);
14353         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14354         e_conv = DecodeError_clone(&e_conv);
14355         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14356         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
14357         return tag_ptr(ret_conv, true);
14358 }
14359
14360 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(uint64_t o) {
14361         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(o);
14362         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
14363         return ret_conv;
14364 }
14365
14366 void  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_free"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_free(uint64_t _res) {
14367         if (!ptr_is_owned(_res)) return;
14368         void* _res_ptr = untag_ptr(_res);
14369         CHECK_ACCESS(_res_ptr);
14370         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
14371         FREE(untag_ptr(_res));
14372         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
14373 }
14374
14375 static inline uint64_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
14376         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14377         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
14378         return tag_ptr(ret_conv, true);
14379 }
14380 int64_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(uint64_t arg) {
14381         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(arg);
14382         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
14383         return ret_conv;
14384 }
14385
14386 uint64_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone(uint64_t orig) {
14387         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(orig);
14388         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14389         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
14390         return tag_ptr(ret_conv, true);
14391 }
14392
14393 uint64_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint64_t o) {
14394         LDKChannelInfo o_conv;
14395         o_conv.inner = untag_ptr(o);
14396         o_conv.is_owned = ptr_is_owned(o);
14397         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14398         o_conv = ChannelInfo_clone(&o_conv);
14399         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14400         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
14401         return tag_ptr(ret_conv, true);
14402 }
14403
14404 uint64_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint64_t e) {
14405         LDKDecodeError e_conv;
14406         e_conv.inner = untag_ptr(e);
14407         e_conv.is_owned = ptr_is_owned(e);
14408         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14409         e_conv = DecodeError_clone(&e_conv);
14410         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14411         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
14412         return tag_ptr(ret_conv, true);
14413 }
14414
14415 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint64_t o) {
14416         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(o);
14417         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
14418         return ret_conv;
14419 }
14420
14421 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint64_t _res) {
14422         if (!ptr_is_owned(_res)) return;
14423         void* _res_ptr = untag_ptr(_res);
14424         CHECK_ACCESS(_res_ptr);
14425         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
14426         FREE(untag_ptr(_res));
14427         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
14428 }
14429
14430 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
14431         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14432         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
14433         return tag_ptr(ret_conv, true);
14434 }
14435 int64_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint64_t arg) {
14436         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(arg);
14437         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
14438         return ret_conv;
14439 }
14440
14441 uint64_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint64_t orig) {
14442         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(orig);
14443         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14444         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
14445         return tag_ptr(ret_conv, true);
14446 }
14447
14448 uint64_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint64_t o) {
14449         LDKRoutingFees o_conv;
14450         o_conv.inner = untag_ptr(o);
14451         o_conv.is_owned = ptr_is_owned(o);
14452         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14453         o_conv = RoutingFees_clone(&o_conv);
14454         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14455         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
14456         return tag_ptr(ret_conv, true);
14457 }
14458
14459 uint64_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint64_t e) {
14460         LDKDecodeError e_conv;
14461         e_conv.inner = untag_ptr(e);
14462         e_conv.is_owned = ptr_is_owned(e);
14463         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14464         e_conv = DecodeError_clone(&e_conv);
14465         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14466         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
14467         return tag_ptr(ret_conv, true);
14468 }
14469
14470 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint64_t o) {
14471         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(o);
14472         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
14473         return ret_conv;
14474 }
14475
14476 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint64_t _res) {
14477         if (!ptr_is_owned(_res)) return;
14478         void* _res_ptr = untag_ptr(_res);
14479         CHECK_ACCESS(_res_ptr);
14480         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
14481         FREE(untag_ptr(_res));
14482         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
14483 }
14484
14485 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
14486         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14487         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
14488         return tag_ptr(ret_conv, true);
14489 }
14490 int64_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint64_t arg) {
14491         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(arg);
14492         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
14493         return ret_conv;
14494 }
14495
14496 uint64_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint64_t orig) {
14497         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(orig);
14498         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14499         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
14500         return tag_ptr(ret_conv, true);
14501 }
14502
14503 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint64_tArray _res) {
14504         LDKCVec_NetAddressZ _res_constr;
14505         _res_constr.datalen = _res->arr_len;
14506         if (_res_constr.datalen > 0)
14507                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14508         else
14509                 _res_constr.data = NULL;
14510         uint64_t* _res_vals = _res->elems;
14511         for (size_t m = 0; m < _res_constr.datalen; m++) {
14512                 uint64_t _res_conv_12 = _res_vals[m];
14513                 void* _res_conv_12_ptr = untag_ptr(_res_conv_12);
14514                 CHECK_ACCESS(_res_conv_12_ptr);
14515                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14516                 FREE(untag_ptr(_res_conv_12));
14517                 _res_constr.data[m] = _res_conv_12_conv;
14518         }
14519         FREE(_res);
14520         CVec_NetAddressZ_free(_res_constr);
14521 }
14522
14523 uint64_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint64_t o) {
14524         LDKNodeAnnouncementInfo o_conv;
14525         o_conv.inner = untag_ptr(o);
14526         o_conv.is_owned = ptr_is_owned(o);
14527         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14528         o_conv = NodeAnnouncementInfo_clone(&o_conv);
14529         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14530         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
14531         return tag_ptr(ret_conv, true);
14532 }
14533
14534 uint64_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint64_t e) {
14535         LDKDecodeError e_conv;
14536         e_conv.inner = untag_ptr(e);
14537         e_conv.is_owned = ptr_is_owned(e);
14538         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14539         e_conv = DecodeError_clone(&e_conv);
14540         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14541         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
14542         return tag_ptr(ret_conv, true);
14543 }
14544
14545 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint64_t o) {
14546         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(o);
14547         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
14548         return ret_conv;
14549 }
14550
14551 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint64_t _res) {
14552         if (!ptr_is_owned(_res)) return;
14553         void* _res_ptr = untag_ptr(_res);
14554         CHECK_ACCESS(_res_ptr);
14555         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
14556         FREE(untag_ptr(_res));
14557         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
14558 }
14559
14560 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
14561         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14562         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
14563         return tag_ptr(ret_conv, true);
14564 }
14565 int64_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint64_t arg) {
14566         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(arg);
14567         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
14568         return ret_conv;
14569 }
14570
14571 uint64_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint64_t orig) {
14572         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(orig);
14573         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14574         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
14575         return tag_ptr(ret_conv, true);
14576 }
14577
14578 uint64_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_ok"))) TS_CResult_NodeAliasDecodeErrorZ_ok(uint64_t o) {
14579         LDKNodeAlias o_conv;
14580         o_conv.inner = untag_ptr(o);
14581         o_conv.is_owned = ptr_is_owned(o);
14582         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14583         o_conv = NodeAlias_clone(&o_conv);
14584         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14585         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
14586         return tag_ptr(ret_conv, true);
14587 }
14588
14589 uint64_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_err"))) TS_CResult_NodeAliasDecodeErrorZ_err(uint64_t e) {
14590         LDKDecodeError e_conv;
14591         e_conv.inner = untag_ptr(e);
14592         e_conv.is_owned = ptr_is_owned(e);
14593         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14594         e_conv = DecodeError_clone(&e_conv);
14595         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14596         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
14597         return tag_ptr(ret_conv, true);
14598 }
14599
14600 jboolean  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_is_ok"))) TS_CResult_NodeAliasDecodeErrorZ_is_ok(uint64_t o) {
14601         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(o);
14602         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
14603         return ret_conv;
14604 }
14605
14606 void  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_free"))) TS_CResult_NodeAliasDecodeErrorZ_free(uint64_t _res) {
14607         if (!ptr_is_owned(_res)) return;
14608         void* _res_ptr = untag_ptr(_res);
14609         CHECK_ACCESS(_res_ptr);
14610         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
14611         FREE(untag_ptr(_res));
14612         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
14613 }
14614
14615 static inline uint64_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
14616         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14617         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
14618         return tag_ptr(ret_conv, true);
14619 }
14620 int64_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAliasDecodeErrorZ_clone_ptr(uint64_t arg) {
14621         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(arg);
14622         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
14623         return ret_conv;
14624 }
14625
14626 uint64_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_clone"))) TS_CResult_NodeAliasDecodeErrorZ_clone(uint64_t orig) {
14627         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(orig);
14628         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14629         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
14630         return tag_ptr(ret_conv, true);
14631 }
14632
14633 uint64_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint64_t o) {
14634         LDKNodeInfo o_conv;
14635         o_conv.inner = untag_ptr(o);
14636         o_conv.is_owned = ptr_is_owned(o);
14637         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14638         o_conv = NodeInfo_clone(&o_conv);
14639         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14640         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
14641         return tag_ptr(ret_conv, true);
14642 }
14643
14644 uint64_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint64_t e) {
14645         LDKDecodeError e_conv;
14646         e_conv.inner = untag_ptr(e);
14647         e_conv.is_owned = ptr_is_owned(e);
14648         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14649         e_conv = DecodeError_clone(&e_conv);
14650         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14651         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
14652         return tag_ptr(ret_conv, true);
14653 }
14654
14655 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint64_t o) {
14656         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(o);
14657         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
14658         return ret_conv;
14659 }
14660
14661 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint64_t _res) {
14662         if (!ptr_is_owned(_res)) return;
14663         void* _res_ptr = untag_ptr(_res);
14664         CHECK_ACCESS(_res_ptr);
14665         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
14666         FREE(untag_ptr(_res));
14667         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
14668 }
14669
14670 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
14671         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14672         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
14673         return tag_ptr(ret_conv, true);
14674 }
14675 int64_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint64_t arg) {
14676         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(arg);
14677         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
14678         return ret_conv;
14679 }
14680
14681 uint64_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint64_t orig) {
14682         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(orig);
14683         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14684         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
14685         return tag_ptr(ret_conv, true);
14686 }
14687
14688 uint64_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint64_t o) {
14689         LDKNetworkGraph o_conv;
14690         o_conv.inner = untag_ptr(o);
14691         o_conv.is_owned = ptr_is_owned(o);
14692         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14693         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
14694         
14695         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14696         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
14697         return tag_ptr(ret_conv, true);
14698 }
14699
14700 uint64_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint64_t e) {
14701         LDKDecodeError e_conv;
14702         e_conv.inner = untag_ptr(e);
14703         e_conv.is_owned = ptr_is_owned(e);
14704         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14705         e_conv = DecodeError_clone(&e_conv);
14706         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14707         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
14708         return tag_ptr(ret_conv, true);
14709 }
14710
14711 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint64_t o) {
14712         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(o);
14713         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
14714         return ret_conv;
14715 }
14716
14717 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint64_t _res) {
14718         if (!ptr_is_owned(_res)) return;
14719         void* _res_ptr = untag_ptr(_res);
14720         CHECK_ACCESS(_res_ptr);
14721         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
14722         FREE(untag_ptr(_res));
14723         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
14724 }
14725
14726 uint64_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint64_tArray o) {
14727         LDKCVec_NetAddressZ o_constr;
14728         o_constr.datalen = o->arr_len;
14729         if (o_constr.datalen > 0)
14730                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14731         else
14732                 o_constr.data = NULL;
14733         uint64_t* o_vals = o->elems;
14734         for (size_t m = 0; m < o_constr.datalen; m++) {
14735                 uint64_t o_conv_12 = o_vals[m];
14736                 void* o_conv_12_ptr = untag_ptr(o_conv_12);
14737                 CHECK_ACCESS(o_conv_12_ptr);
14738                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
14739                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o_conv_12));
14740                 o_constr.data[m] = o_conv_12_conv;
14741         }
14742         FREE(o);
14743         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14744         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
14745         uint64_t ret_ref = tag_ptr(ret_copy, true);
14746         return ret_ref;
14747 }
14748
14749 uint64_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
14750         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14751         *ret_copy = COption_CVec_NetAddressZZ_none();
14752         uint64_t ret_ref = tag_ptr(ret_copy, true);
14753         return ret_ref;
14754 }
14755
14756 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint64_t _res) {
14757         if (!ptr_is_owned(_res)) return;
14758         void* _res_ptr = untag_ptr(_res);
14759         CHECK_ACCESS(_res_ptr);
14760         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
14761         FREE(untag_ptr(_res));
14762         COption_CVec_NetAddressZZ_free(_res_conv);
14763 }
14764
14765 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
14766         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14767         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
14768         uint64_t ret_ref = tag_ptr(ret_copy, true);
14769         return ret_ref;
14770 }
14771 int64_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint64_t arg) {
14772         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(arg);
14773         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
14774         return ret_conv;
14775 }
14776
14777 uint64_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint64_t orig) {
14778         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(orig);
14779         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14780         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
14781         uint64_t ret_ref = tag_ptr(ret_copy, true);
14782         return ret_ref;
14783 }
14784
14785 uint64_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint64_t o) {
14786         LDKDelayedPaymentOutputDescriptor o_conv;
14787         o_conv.inner = untag_ptr(o);
14788         o_conv.is_owned = ptr_is_owned(o);
14789         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14790         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
14791         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14792         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14793         return tag_ptr(ret_conv, true);
14794 }
14795
14796 uint64_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint64_t e) {
14797         LDKDecodeError e_conv;
14798         e_conv.inner = untag_ptr(e);
14799         e_conv.is_owned = ptr_is_owned(e);
14800         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14801         e_conv = DecodeError_clone(&e_conv);
14802         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14803         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14804         return tag_ptr(ret_conv, true);
14805 }
14806
14807 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint64_t o) {
14808         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
14809         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14810         return ret_conv;
14811 }
14812
14813 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint64_t _res) {
14814         if (!ptr_is_owned(_res)) return;
14815         void* _res_ptr = untag_ptr(_res);
14816         CHECK_ACCESS(_res_ptr);
14817         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14818         FREE(untag_ptr(_res));
14819         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14820 }
14821
14822 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14823         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14824         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14825         return tag_ptr(ret_conv, true);
14826 }
14827 int64_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint64_t arg) {
14828         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
14829         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14830         return ret_conv;
14831 }
14832
14833 uint64_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint64_t orig) {
14834         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
14835         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14836         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
14837         return tag_ptr(ret_conv, true);
14838 }
14839
14840 uint64_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint64_t o) {
14841         LDKStaticPaymentOutputDescriptor o_conv;
14842         o_conv.inner = untag_ptr(o);
14843         o_conv.is_owned = ptr_is_owned(o);
14844         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14845         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
14846         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14847         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14848         return tag_ptr(ret_conv, true);
14849 }
14850
14851 uint64_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint64_t e) {
14852         LDKDecodeError e_conv;
14853         e_conv.inner = untag_ptr(e);
14854         e_conv.is_owned = ptr_is_owned(e);
14855         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14856         e_conv = DecodeError_clone(&e_conv);
14857         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14858         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14859         return tag_ptr(ret_conv, true);
14860 }
14861
14862 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint64_t o) {
14863         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
14864         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14865         return ret_conv;
14866 }
14867
14868 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint64_t _res) {
14869         if (!ptr_is_owned(_res)) return;
14870         void* _res_ptr = untag_ptr(_res);
14871         CHECK_ACCESS(_res_ptr);
14872         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14873         FREE(untag_ptr(_res));
14874         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14875 }
14876
14877 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14878         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14879         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14880         return tag_ptr(ret_conv, true);
14881 }
14882 int64_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint64_t arg) {
14883         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
14884         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14885         return ret_conv;
14886 }
14887
14888 uint64_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint64_t orig) {
14889         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
14890         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14891         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
14892         return tag_ptr(ret_conv, true);
14893 }
14894
14895 uint64_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint64_t o) {
14896         void* o_ptr = untag_ptr(o);
14897         CHECK_ACCESS(o_ptr);
14898         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
14899         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(o));
14900         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14901         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
14902         return tag_ptr(ret_conv, true);
14903 }
14904
14905 uint64_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint64_t e) {
14906         LDKDecodeError e_conv;
14907         e_conv.inner = untag_ptr(e);
14908         e_conv.is_owned = ptr_is_owned(e);
14909         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14910         e_conv = DecodeError_clone(&e_conv);
14911         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14912         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
14913         return tag_ptr(ret_conv, true);
14914 }
14915
14916 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint64_t o) {
14917         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(o);
14918         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14919         return ret_conv;
14920 }
14921
14922 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint64_t _res) {
14923         if (!ptr_is_owned(_res)) return;
14924         void* _res_ptr = untag_ptr(_res);
14925         CHECK_ACCESS(_res_ptr);
14926         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
14927         FREE(untag_ptr(_res));
14928         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
14929 }
14930
14931 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14932         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14933         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
14934         return tag_ptr(ret_conv, true);
14935 }
14936 int64_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint64_t arg) {
14937         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
14938         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14939         return ret_conv;
14940 }
14941
14942 uint64_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint64_t orig) {
14943         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
14944         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14945         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
14946         return tag_ptr(ret_conv, true);
14947 }
14948
14949 void  __attribute__((export_name("TS_CVec_PaymentPreimageZ_free"))) TS_CVec_PaymentPreimageZ_free(ptrArray _res) {
14950         LDKCVec_PaymentPreimageZ _res_constr;
14951         _res_constr.datalen = _res->arr_len;
14952         if (_res_constr.datalen > 0)
14953                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
14954         else
14955                 _res_constr.data = NULL;
14956         int8_tArray* _res_vals = (void*) _res->elems;
14957         for (size_t m = 0; m < _res_constr.datalen; m++) {
14958                 int8_tArray _res_conv_12 = _res_vals[m];
14959                 LDKThirtyTwoBytes _res_conv_12_ref;
14960                 CHECK(_res_conv_12->arr_len == 32);
14961                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
14962                 _res_constr.data[m] = _res_conv_12_ref;
14963         }
14964         FREE(_res);
14965         CVec_PaymentPreimageZ_free(_res_constr);
14966 }
14967
14968 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
14969         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
14970         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
14971         return tag_ptr(ret_conv, true);
14972 }
14973 int64_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint64_t arg) {
14974         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(arg);
14975         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
14976         return ret_conv;
14977 }
14978
14979 uint64_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint64_t orig) {
14980         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(orig);
14981         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
14982         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
14983         return tag_ptr(ret_conv, true);
14984 }
14985
14986 uint64_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
14987         LDKSignature a_ref;
14988         CHECK(a->arr_len == 64);
14989         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
14990         LDKCVec_SignatureZ b_constr;
14991         b_constr.datalen = b->arr_len;
14992         if (b_constr.datalen > 0)
14993                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14994         else
14995                 b_constr.data = NULL;
14996         int8_tArray* b_vals = (void*) b->elems;
14997         for (size_t m = 0; m < b_constr.datalen; m++) {
14998                 int8_tArray b_conv_12 = b_vals[m];
14999                 LDKSignature b_conv_12_ref;
15000                 CHECK(b_conv_12->arr_len == 64);
15001                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
15002                 b_constr.data[m] = b_conv_12_ref;
15003         }
15004         FREE(b);
15005         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15006         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
15007         return tag_ptr(ret_conv, true);
15008 }
15009
15010 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint64_t _res) {
15011         if (!ptr_is_owned(_res)) return;
15012         void* _res_ptr = untag_ptr(_res);
15013         CHECK_ACCESS(_res_ptr);
15014         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
15015         FREE(untag_ptr(_res));
15016         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
15017 }
15018
15019 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint64_t o) {
15020         void* o_ptr = untag_ptr(o);
15021         CHECK_ACCESS(o_ptr);
15022         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
15023         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(o));
15024         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15025         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
15026         return tag_ptr(ret_conv, true);
15027 }
15028
15029 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
15030         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15031         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
15032         return tag_ptr(ret_conv, true);
15033 }
15034
15035 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint64_t o) {
15036         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(o);
15037         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
15038         return ret_conv;
15039 }
15040
15041 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint64_t _res) {
15042         if (!ptr_is_owned(_res)) return;
15043         void* _res_ptr = untag_ptr(_res);
15044         CHECK_ACCESS(_res_ptr);
15045         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
15046         FREE(untag_ptr(_res));
15047         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
15048 }
15049
15050 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
15051         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15052         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
15053         return tag_ptr(ret_conv, true);
15054 }
15055 int64_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint64_t arg) {
15056         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(arg);
15057         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
15058         return ret_conv;
15059 }
15060
15061 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint64_t orig) {
15062         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(orig);
15063         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15064         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
15065         return tag_ptr(ret_conv, true);
15066 }
15067
15068 uint64_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
15069         LDKSignature o_ref;
15070         CHECK(o->arr_len == 64);
15071         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
15072         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15073         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
15074         return tag_ptr(ret_conv, true);
15075 }
15076
15077 uint64_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
15078         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15079         *ret_conv = CResult_SignatureNoneZ_err();
15080         return tag_ptr(ret_conv, true);
15081 }
15082
15083 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint64_t o) {
15084         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(o);
15085         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
15086         return ret_conv;
15087 }
15088
15089 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint64_t _res) {
15090         if (!ptr_is_owned(_res)) return;
15091         void* _res_ptr = untag_ptr(_res);
15092         CHECK_ACCESS(_res_ptr);
15093         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
15094         FREE(untag_ptr(_res));
15095         CResult_SignatureNoneZ_free(_res_conv);
15096 }
15097
15098 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
15099         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15100         *ret_conv = CResult_SignatureNoneZ_clone(arg);
15101         return tag_ptr(ret_conv, true);
15102 }
15103 int64_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint64_t arg) {
15104         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(arg);
15105         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
15106         return ret_conv;
15107 }
15108
15109 uint64_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint64_t orig) {
15110         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(orig);
15111         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15112         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
15113         return tag_ptr(ret_conv, true);
15114 }
15115
15116 static inline uint64_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
15117         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
15118         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
15119         return tag_ptr(ret_conv, true);
15120 }
15121 int64_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone_ptr"))) TS_C2Tuple_SignatureSignatureZ_clone_ptr(uint64_t arg) {
15122         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(arg);
15123         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
15124         return ret_conv;
15125 }
15126
15127 uint64_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone"))) TS_C2Tuple_SignatureSignatureZ_clone(uint64_t orig) {
15128         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(orig);
15129         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
15130         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
15131         return tag_ptr(ret_conv, true);
15132 }
15133
15134 uint64_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_new"))) TS_C2Tuple_SignatureSignatureZ_new(int8_tArray a, int8_tArray b) {
15135         LDKSignature a_ref;
15136         CHECK(a->arr_len == 64);
15137         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
15138         LDKSignature b_ref;
15139         CHECK(b->arr_len == 64);
15140         memcpy(b_ref.compact_form, b->elems, 64); FREE(b);
15141         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
15142         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
15143         return tag_ptr(ret_conv, true);
15144 }
15145
15146 void  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_free"))) TS_C2Tuple_SignatureSignatureZ_free(uint64_t _res) {
15147         if (!ptr_is_owned(_res)) return;
15148         void* _res_ptr = untag_ptr(_res);
15149         CHECK_ACCESS(_res_ptr);
15150         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
15151         FREE(untag_ptr(_res));
15152         C2Tuple_SignatureSignatureZ_free(_res_conv);
15153 }
15154
15155 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok(uint64_t o) {
15156         void* o_ptr = untag_ptr(o);
15157         CHECK_ACCESS(o_ptr);
15158         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
15159         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)untag_ptr(o));
15160         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15161         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
15162         return tag_ptr(ret_conv, true);
15163 }
15164
15165 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err() {
15166         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15167         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
15168         return tag_ptr(ret_conv, true);
15169 }
15170
15171 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(uint64_t o) {
15172         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(o);
15173         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
15174         return ret_conv;
15175 }
15176
15177 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free(uint64_t _res) {
15178         if (!ptr_is_owned(_res)) return;
15179         void* _res_ptr = untag_ptr(_res);
15180         CHECK_ACCESS(_res_ptr);
15181         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
15182         FREE(untag_ptr(_res));
15183         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
15184 }
15185
15186 static inline uint64_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
15187         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15188         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
15189         return tag_ptr(ret_conv, true);
15190 }
15191 int64_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(uint64_t arg) {
15192         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(arg);
15193         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
15194         return ret_conv;
15195 }
15196
15197 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone(uint64_t orig) {
15198         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(orig);
15199         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15200         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
15201         return tag_ptr(ret_conv, true);
15202 }
15203
15204 uint64_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_ok"))) TS_CResult_SecretKeyNoneZ_ok(int8_tArray o) {
15205         LDKSecretKey o_ref;
15206         CHECK(o->arr_len == 32);
15207         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
15208         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15209         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
15210         return tag_ptr(ret_conv, true);
15211 }
15212
15213 uint64_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_err"))) TS_CResult_SecretKeyNoneZ_err() {
15214         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15215         *ret_conv = CResult_SecretKeyNoneZ_err();
15216         return tag_ptr(ret_conv, true);
15217 }
15218
15219 jboolean  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_is_ok"))) TS_CResult_SecretKeyNoneZ_is_ok(uint64_t o) {
15220         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(o);
15221         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
15222         return ret_conv;
15223 }
15224
15225 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_free"))) TS_CResult_SecretKeyNoneZ_free(uint64_t _res) {
15226         if (!ptr_is_owned(_res)) return;
15227         void* _res_ptr = untag_ptr(_res);
15228         CHECK_ACCESS(_res_ptr);
15229         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
15230         FREE(untag_ptr(_res));
15231         CResult_SecretKeyNoneZ_free(_res_conv);
15232 }
15233
15234 static inline uint64_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
15235         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15236         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
15237         return tag_ptr(ret_conv, true);
15238 }
15239 int64_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone_ptr"))) TS_CResult_SecretKeyNoneZ_clone_ptr(uint64_t arg) {
15240         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(arg);
15241         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
15242         return ret_conv;
15243 }
15244
15245 uint64_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone"))) TS_CResult_SecretKeyNoneZ_clone(uint64_t orig) {
15246         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(orig);
15247         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15248         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
15249         return tag_ptr(ret_conv, true);
15250 }
15251
15252 uint64_t  __attribute__((export_name("TS_COption_ScalarZ_some"))) TS_COption_ScalarZ_some(uint64_t o) {
15253         void* o_ptr = untag_ptr(o);
15254         CHECK_ACCESS(o_ptr);
15255         LDKBigEndianScalar o_conv = *(LDKBigEndianScalar*)(o_ptr);
15256         // WARNING: we may need a move here but no clone is available for LDKBigEndianScalar
15257         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
15258         *ret_copy = COption_ScalarZ_some(o_conv);
15259         uint64_t ret_ref = tag_ptr(ret_copy, true);
15260         return ret_ref;
15261 }
15262
15263 uint64_t  __attribute__((export_name("TS_COption_ScalarZ_none"))) TS_COption_ScalarZ_none() {
15264         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
15265         *ret_copy = COption_ScalarZ_none();
15266         uint64_t ret_ref = tag_ptr(ret_copy, true);
15267         return ret_ref;
15268 }
15269
15270 void  __attribute__((export_name("TS_COption_ScalarZ_free"))) TS_COption_ScalarZ_free(uint64_t _res) {
15271         if (!ptr_is_owned(_res)) return;
15272         void* _res_ptr = untag_ptr(_res);
15273         CHECK_ACCESS(_res_ptr);
15274         LDKCOption_ScalarZ _res_conv = *(LDKCOption_ScalarZ*)(_res_ptr);
15275         FREE(untag_ptr(_res));
15276         COption_ScalarZ_free(_res_conv);
15277 }
15278
15279 uint64_t  __attribute__((export_name("TS_CResult_SharedSecretNoneZ_ok"))) TS_CResult_SharedSecretNoneZ_ok(int8_tArray o) {
15280         LDKThirtyTwoBytes o_ref;
15281         CHECK(o->arr_len == 32);
15282         memcpy(o_ref.data, o->elems, 32); FREE(o);
15283         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
15284         *ret_conv = CResult_SharedSecretNoneZ_ok(o_ref);
15285         return tag_ptr(ret_conv, true);
15286 }
15287
15288 uint64_t  __attribute__((export_name("TS_CResult_SharedSecretNoneZ_err"))) TS_CResult_SharedSecretNoneZ_err() {
15289         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
15290         *ret_conv = CResult_SharedSecretNoneZ_err();
15291         return tag_ptr(ret_conv, true);
15292 }
15293
15294 jboolean  __attribute__((export_name("TS_CResult_SharedSecretNoneZ_is_ok"))) TS_CResult_SharedSecretNoneZ_is_ok(uint64_t o) {
15295         LDKCResult_SharedSecretNoneZ* o_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(o);
15296         jboolean ret_conv = CResult_SharedSecretNoneZ_is_ok(o_conv);
15297         return ret_conv;
15298 }
15299
15300 void  __attribute__((export_name("TS_CResult_SharedSecretNoneZ_free"))) TS_CResult_SharedSecretNoneZ_free(uint64_t _res) {
15301         if (!ptr_is_owned(_res)) return;
15302         void* _res_ptr = untag_ptr(_res);
15303         CHECK_ACCESS(_res_ptr);
15304         LDKCResult_SharedSecretNoneZ _res_conv = *(LDKCResult_SharedSecretNoneZ*)(_res_ptr);
15305         FREE(untag_ptr(_res));
15306         CResult_SharedSecretNoneZ_free(_res_conv);
15307 }
15308
15309 static inline uint64_t CResult_SharedSecretNoneZ_clone_ptr(LDKCResult_SharedSecretNoneZ *NONNULL_PTR arg) {
15310         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
15311         *ret_conv = CResult_SharedSecretNoneZ_clone(arg);
15312         return tag_ptr(ret_conv, true);
15313 }
15314 int64_t  __attribute__((export_name("TS_CResult_SharedSecretNoneZ_clone_ptr"))) TS_CResult_SharedSecretNoneZ_clone_ptr(uint64_t arg) {
15315         LDKCResult_SharedSecretNoneZ* arg_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(arg);
15316         int64_t ret_conv = CResult_SharedSecretNoneZ_clone_ptr(arg_conv);
15317         return ret_conv;
15318 }
15319
15320 uint64_t  __attribute__((export_name("TS_CResult_SharedSecretNoneZ_clone"))) TS_CResult_SharedSecretNoneZ_clone(uint64_t orig) {
15321         LDKCResult_SharedSecretNoneZ* orig_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(orig);
15322         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
15323         *ret_conv = CResult_SharedSecretNoneZ_clone(orig_conv);
15324         return tag_ptr(ret_conv, true);
15325 }
15326
15327 uint64_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint64_t o) {
15328         void* o_ptr = untag_ptr(o);
15329         CHECK_ACCESS(o_ptr);
15330         LDKSign o_conv = *(LDKSign*)(o_ptr);
15331         if (o_conv.free == LDKSign_JCalls_free) {
15332                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15333                 LDKSign_JCalls_cloned(&o_conv);
15334         }
15335         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15336         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
15337         return tag_ptr(ret_conv, true);
15338 }
15339
15340 uint64_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint64_t e) {
15341         LDKDecodeError e_conv;
15342         e_conv.inner = untag_ptr(e);
15343         e_conv.is_owned = ptr_is_owned(e);
15344         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15345         e_conv = DecodeError_clone(&e_conv);
15346         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15347         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
15348         return tag_ptr(ret_conv, true);
15349 }
15350
15351 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint64_t o) {
15352         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(o);
15353         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
15354         return ret_conv;
15355 }
15356
15357 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint64_t _res) {
15358         if (!ptr_is_owned(_res)) return;
15359         void* _res_ptr = untag_ptr(_res);
15360         CHECK_ACCESS(_res_ptr);
15361         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
15362         FREE(untag_ptr(_res));
15363         CResult_SignDecodeErrorZ_free(_res_conv);
15364 }
15365
15366 static inline uint64_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
15367         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15368         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
15369         return tag_ptr(ret_conv, true);
15370 }
15371 int64_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint64_t arg) {
15372         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(arg);
15373         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
15374         return ret_conv;
15375 }
15376
15377 uint64_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint64_t orig) {
15378         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(orig);
15379         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15380         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
15381         return tag_ptr(ret_conv, true);
15382 }
15383
15384 void  __attribute__((export_name("TS_CVec_u5Z_free"))) TS_CVec_u5Z_free(ptrArray _res) {
15385         LDKCVec_u5Z _res_constr;
15386         _res_constr.datalen = _res->arr_len;
15387         if (_res_constr.datalen > 0)
15388                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
15389         else
15390                 _res_constr.data = NULL;
15391         int8_t* _res_vals = (void*) _res->elems;
15392         for (size_t h = 0; h < _res_constr.datalen; h++) {
15393                 int8_t _res_conv_7 = _res_vals[h];
15394                 
15395                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
15396         }
15397         FREE(_res);
15398         CVec_u5Z_free(_res_constr);
15399 }
15400
15401 uint64_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
15402         LDKRecoverableSignature o_ref;
15403         CHECK(o->arr_len == 68);
15404         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
15405         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15406         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
15407         return tag_ptr(ret_conv, true);
15408 }
15409
15410 uint64_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
15411         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15412         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
15413         return tag_ptr(ret_conv, true);
15414 }
15415
15416 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint64_t o) {
15417         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(o);
15418         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
15419         return ret_conv;
15420 }
15421
15422 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint64_t _res) {
15423         if (!ptr_is_owned(_res)) return;
15424         void* _res_ptr = untag_ptr(_res);
15425         CHECK_ACCESS(_res_ptr);
15426         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
15427         FREE(untag_ptr(_res));
15428         CResult_RecoverableSignatureNoneZ_free(_res_conv);
15429 }
15430
15431 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
15432         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15433         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
15434         return tag_ptr(ret_conv, true);
15435 }
15436 int64_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint64_t arg) {
15437         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(arg);
15438         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
15439         return ret_conv;
15440 }
15441
15442 uint64_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint64_t orig) {
15443         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(orig);
15444         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15445         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
15446         return tag_ptr(ret_conv, true);
15447 }
15448
15449 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
15450         LDKCVec_u8Z _res_ref;
15451         _res_ref.datalen = _res->arr_len;
15452         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
15453         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
15454         CVec_u8Z_free(_res_ref);
15455 }
15456
15457 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
15458         LDKCVec_CVec_u8ZZ _res_constr;
15459         _res_constr.datalen = _res->arr_len;
15460         if (_res_constr.datalen > 0)
15461                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15462         else
15463                 _res_constr.data = NULL;
15464         int8_tArray* _res_vals = (void*) _res->elems;
15465         for (size_t m = 0; m < _res_constr.datalen; m++) {
15466                 int8_tArray _res_conv_12 = _res_vals[m];
15467                 LDKCVec_u8Z _res_conv_12_ref;
15468                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
15469                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15470                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
15471                 _res_constr.data[m] = _res_conv_12_ref;
15472         }
15473         FREE(_res);
15474         CVec_CVec_u8ZZ_free(_res_constr);
15475 }
15476
15477 uint64_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
15478         LDKCVec_CVec_u8ZZ o_constr;
15479         o_constr.datalen = o->arr_len;
15480         if (o_constr.datalen > 0)
15481                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15482         else
15483                 o_constr.data = NULL;
15484         int8_tArray* o_vals = (void*) o->elems;
15485         for (size_t m = 0; m < o_constr.datalen; m++) {
15486                 int8_tArray o_conv_12 = o_vals[m];
15487                 LDKCVec_u8Z o_conv_12_ref;
15488                 o_conv_12_ref.datalen = o_conv_12->arr_len;
15489                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15490                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
15491                 o_constr.data[m] = o_conv_12_ref;
15492         }
15493         FREE(o);
15494         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15495         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
15496         return tag_ptr(ret_conv, true);
15497 }
15498
15499 uint64_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
15500         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15501         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
15502         return tag_ptr(ret_conv, true);
15503 }
15504
15505 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint64_t o) {
15506         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(o);
15507         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
15508         return ret_conv;
15509 }
15510
15511 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint64_t _res) {
15512         if (!ptr_is_owned(_res)) return;
15513         void* _res_ptr = untag_ptr(_res);
15514         CHECK_ACCESS(_res_ptr);
15515         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
15516         FREE(untag_ptr(_res));
15517         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
15518 }
15519
15520 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
15521         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15522         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
15523         return tag_ptr(ret_conv, true);
15524 }
15525 int64_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint64_t arg) {
15526         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(arg);
15527         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
15528         return ret_conv;
15529 }
15530
15531 uint64_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint64_t orig) {
15532         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(orig);
15533         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15534         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
15535         return tag_ptr(ret_conv, true);
15536 }
15537
15538 uint64_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint64_t o) {
15539         LDKInMemorySigner o_conv;
15540         o_conv.inner = untag_ptr(o);
15541         o_conv.is_owned = ptr_is_owned(o);
15542         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15543         o_conv = InMemorySigner_clone(&o_conv);
15544         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15545         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
15546         return tag_ptr(ret_conv, true);
15547 }
15548
15549 uint64_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint64_t e) {
15550         LDKDecodeError e_conv;
15551         e_conv.inner = untag_ptr(e);
15552         e_conv.is_owned = ptr_is_owned(e);
15553         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15554         e_conv = DecodeError_clone(&e_conv);
15555         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15556         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
15557         return tag_ptr(ret_conv, true);
15558 }
15559
15560 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint64_t o) {
15561         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(o);
15562         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
15563         return ret_conv;
15564 }
15565
15566 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint64_t _res) {
15567         if (!ptr_is_owned(_res)) return;
15568         void* _res_ptr = untag_ptr(_res);
15569         CHECK_ACCESS(_res_ptr);
15570         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
15571         FREE(untag_ptr(_res));
15572         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
15573 }
15574
15575 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
15576         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15577         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
15578         return tag_ptr(ret_conv, true);
15579 }
15580 int64_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint64_t arg) {
15581         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(arg);
15582         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
15583         return ret_conv;
15584 }
15585
15586 uint64_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint64_t orig) {
15587         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(orig);
15588         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15589         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
15590         return tag_ptr(ret_conv, true);
15591 }
15592
15593 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint64_tArray _res) {
15594         LDKCVec_TxOutZ _res_constr;
15595         _res_constr.datalen = _res->arr_len;
15596         if (_res_constr.datalen > 0)
15597                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15598         else
15599                 _res_constr.data = NULL;
15600         uint64_t* _res_vals = _res->elems;
15601         for (size_t h = 0; h < _res_constr.datalen; h++) {
15602                 uint64_t _res_conv_7 = _res_vals[h];
15603                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
15604                 CHECK_ACCESS(_res_conv_7_ptr);
15605                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
15606                 FREE(untag_ptr(_res_conv_7));
15607                 _res_constr.data[h] = _res_conv_7_conv;
15608         }
15609         FREE(_res);
15610         CVec_TxOutZ_free(_res_constr);
15611 }
15612
15613 uint64_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
15614         LDKTransaction o_ref;
15615         o_ref.datalen = o->arr_len;
15616         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
15617         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
15618         o_ref.data_is_owned = true;
15619         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15620         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
15621         return tag_ptr(ret_conv, true);
15622 }
15623
15624 uint64_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
15625         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15626         *ret_conv = CResult_TransactionNoneZ_err();
15627         return tag_ptr(ret_conv, true);
15628 }
15629
15630 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint64_t o) {
15631         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(o);
15632         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
15633         return ret_conv;
15634 }
15635
15636 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint64_t _res) {
15637         if (!ptr_is_owned(_res)) return;
15638         void* _res_ptr = untag_ptr(_res);
15639         CHECK_ACCESS(_res_ptr);
15640         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
15641         FREE(untag_ptr(_res));
15642         CResult_TransactionNoneZ_free(_res_conv);
15643 }
15644
15645 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
15646         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15647         *ret_conv = CResult_TransactionNoneZ_clone(arg);
15648         return tag_ptr(ret_conv, true);
15649 }
15650 int64_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint64_t arg) {
15651         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(arg);
15652         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
15653         return ret_conv;
15654 }
15655
15656 uint64_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint64_t orig) {
15657         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(orig);
15658         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15659         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
15660         return tag_ptr(ret_conv, true);
15661 }
15662
15663 uint64_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
15664         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15665         *ret_copy = COption_u16Z_some(o);
15666         uint64_t ret_ref = tag_ptr(ret_copy, true);
15667         return ret_ref;
15668 }
15669
15670 uint64_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
15671         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15672         *ret_copy = COption_u16Z_none();
15673         uint64_t ret_ref = tag_ptr(ret_copy, true);
15674         return ret_ref;
15675 }
15676
15677 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint64_t _res) {
15678         if (!ptr_is_owned(_res)) return;
15679         void* _res_ptr = untag_ptr(_res);
15680         CHECK_ACCESS(_res_ptr);
15681         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
15682         FREE(untag_ptr(_res));
15683         COption_u16Z_free(_res_conv);
15684 }
15685
15686 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
15687         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15688         *ret_copy = COption_u16Z_clone(arg);
15689         uint64_t ret_ref = tag_ptr(ret_copy, true);
15690         return ret_ref;
15691 }
15692 int64_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint64_t arg) {
15693         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)untag_ptr(arg);
15694         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
15695         return ret_conv;
15696 }
15697
15698 uint64_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint64_t orig) {
15699         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)untag_ptr(orig);
15700         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15701         *ret_copy = COption_u16Z_clone(orig_conv);
15702         uint64_t ret_ref = tag_ptr(ret_copy, true);
15703         return ret_ref;
15704 }
15705
15706 uint64_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
15707         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15708         *ret_conv = CResult_NoneAPIErrorZ_ok();
15709         return tag_ptr(ret_conv, true);
15710 }
15711
15712 uint64_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint64_t e) {
15713         void* e_ptr = untag_ptr(e);
15714         CHECK_ACCESS(e_ptr);
15715         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15716         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
15717         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15718         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
15719         return tag_ptr(ret_conv, true);
15720 }
15721
15722 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint64_t o) {
15723         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(o);
15724         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
15725         return ret_conv;
15726 }
15727
15728 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint64_t _res) {
15729         if (!ptr_is_owned(_res)) return;
15730         void* _res_ptr = untag_ptr(_res);
15731         CHECK_ACCESS(_res_ptr);
15732         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
15733         FREE(untag_ptr(_res));
15734         CResult_NoneAPIErrorZ_free(_res_conv);
15735 }
15736
15737 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
15738         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15739         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
15740         return tag_ptr(ret_conv, true);
15741 }
15742 int64_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint64_t arg) {
15743         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(arg);
15744         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
15745         return ret_conv;
15746 }
15747
15748 uint64_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint64_t orig) {
15749         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(orig);
15750         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15751         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
15752         return tag_ptr(ret_conv, true);
15753 }
15754
15755 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint64_tArray _res) {
15756         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
15757         _res_constr.datalen = _res->arr_len;
15758         if (_res_constr.datalen > 0)
15759                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15760         else
15761                 _res_constr.data = NULL;
15762         uint64_t* _res_vals = _res->elems;
15763         for (size_t w = 0; w < _res_constr.datalen; w++) {
15764                 uint64_t _res_conv_22 = _res_vals[w];
15765                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
15766                 CHECK_ACCESS(_res_conv_22_ptr);
15767                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
15768                 FREE(untag_ptr(_res_conv_22));
15769                 _res_constr.data[w] = _res_conv_22_conv;
15770         }
15771         FREE(_res);
15772         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
15773 }
15774
15775 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint64_tArray _res) {
15776         LDKCVec_APIErrorZ _res_constr;
15777         _res_constr.datalen = _res->arr_len;
15778         if (_res_constr.datalen > 0)
15779                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15780         else
15781                 _res_constr.data = NULL;
15782         uint64_t* _res_vals = _res->elems;
15783         for (size_t k = 0; k < _res_constr.datalen; k++) {
15784                 uint64_t _res_conv_10 = _res_vals[k];
15785                 void* _res_conv_10_ptr = untag_ptr(_res_conv_10);
15786                 CHECK_ACCESS(_res_conv_10_ptr);
15787                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
15788                 FREE(untag_ptr(_res_conv_10));
15789                 _res_constr.data[k] = _res_conv_10_conv;
15790         }
15791         FREE(_res);
15792         CVec_APIErrorZ_free(_res_constr);
15793 }
15794
15795 uint64_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
15796         LDKThirtyTwoBytes o_ref;
15797         CHECK(o->arr_len == 32);
15798         memcpy(o_ref.data, o->elems, 32); FREE(o);
15799         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15800         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
15801         return tag_ptr(ret_conv, true);
15802 }
15803
15804 uint64_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint64_t e) {
15805         void* e_ptr = untag_ptr(e);
15806         CHECK_ACCESS(e_ptr);
15807         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15808         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
15809         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15810         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
15811         return tag_ptr(ret_conv, true);
15812 }
15813
15814 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint64_t o) {
15815         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(o);
15816         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
15817         return ret_conv;
15818 }
15819
15820 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint64_t _res) {
15821         if (!ptr_is_owned(_res)) return;
15822         void* _res_ptr = untag_ptr(_res);
15823         CHECK_ACCESS(_res_ptr);
15824         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
15825         FREE(untag_ptr(_res));
15826         CResult__u832APIErrorZ_free(_res_conv);
15827 }
15828
15829 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
15830         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15831         *ret_conv = CResult__u832APIErrorZ_clone(arg);
15832         return tag_ptr(ret_conv, true);
15833 }
15834 int64_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint64_t arg) {
15835         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(arg);
15836         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
15837         return ret_conv;
15838 }
15839
15840 uint64_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint64_t orig) {
15841         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(orig);
15842         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15843         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
15844         return tag_ptr(ret_conv, true);
15845 }
15846
15847 uint64_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
15848         LDKThirtyTwoBytes o_ref;
15849         CHECK(o->arr_len == 32);
15850         memcpy(o_ref.data, o->elems, 32); FREE(o);
15851         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15852         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
15853         return tag_ptr(ret_conv, true);
15854 }
15855
15856 uint64_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint64_t e) {
15857         void* e_ptr = untag_ptr(e);
15858         CHECK_ACCESS(e_ptr);
15859         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15860         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
15861         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15862         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
15863         return tag_ptr(ret_conv, true);
15864 }
15865
15866 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint64_t o) {
15867         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(o);
15868         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
15869         return ret_conv;
15870 }
15871
15872 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint64_t _res) {
15873         if (!ptr_is_owned(_res)) return;
15874         void* _res_ptr = untag_ptr(_res);
15875         CHECK_ACCESS(_res_ptr);
15876         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
15877         FREE(untag_ptr(_res));
15878         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
15879 }
15880
15881 static inline uint64_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
15882         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15883         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
15884         return tag_ptr(ret_conv, true);
15885 }
15886 int64_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint64_t arg) {
15887         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(arg);
15888         int64_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
15889         return ret_conv;
15890 }
15891
15892 uint64_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint64_t orig) {
15893         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(orig);
15894         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15895         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
15896         return tag_ptr(ret_conv, true);
15897 }
15898
15899 uint64_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
15900         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15901         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
15902         return tag_ptr(ret_conv, true);
15903 }
15904
15905 uint64_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint64_t e) {
15906         void* e_ptr = untag_ptr(e);
15907         CHECK_ACCESS(e_ptr);
15908         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15909         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
15910         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15911         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
15912         return tag_ptr(ret_conv, true);
15913 }
15914
15915 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint64_t o) {
15916         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(o);
15917         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
15918         return ret_conv;
15919 }
15920
15921 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint64_t _res) {
15922         if (!ptr_is_owned(_res)) return;
15923         void* _res_ptr = untag_ptr(_res);
15924         CHECK_ACCESS(_res_ptr);
15925         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
15926         FREE(untag_ptr(_res));
15927         CResult_NonePaymentSendFailureZ_free(_res_conv);
15928 }
15929
15930 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
15931         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15932         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
15933         return tag_ptr(ret_conv, true);
15934 }
15935 int64_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint64_t arg) {
15936         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(arg);
15937         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
15938         return ret_conv;
15939 }
15940
15941 uint64_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint64_t orig) {
15942         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(orig);
15943         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15944         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
15945         return tag_ptr(ret_conv, true);
15946 }
15947
15948 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
15949         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15950         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
15951         return tag_ptr(ret_conv, true);
15952 }
15953 int64_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint64_t arg) {
15954         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(arg);
15955         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
15956         return ret_conv;
15957 }
15958
15959 uint64_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint64_t orig) {
15960         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(orig);
15961         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15962         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
15963         return tag_ptr(ret_conv, true);
15964 }
15965
15966 uint64_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
15967         LDKThirtyTwoBytes a_ref;
15968         CHECK(a->arr_len == 32);
15969         memcpy(a_ref.data, a->elems, 32); FREE(a);
15970         LDKThirtyTwoBytes b_ref;
15971         CHECK(b->arr_len == 32);
15972         memcpy(b_ref.data, b->elems, 32); FREE(b);
15973         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15974         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
15975         return tag_ptr(ret_conv, true);
15976 }
15977
15978 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint64_t _res) {
15979         if (!ptr_is_owned(_res)) return;
15980         void* _res_ptr = untag_ptr(_res);
15981         CHECK_ACCESS(_res_ptr);
15982         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
15983         FREE(untag_ptr(_res));
15984         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
15985 }
15986
15987 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint64_t o) {
15988         void* o_ptr = untag_ptr(o);
15989         CHECK_ACCESS(o_ptr);
15990         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
15991         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(o));
15992         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15993         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
15994         return tag_ptr(ret_conv, true);
15995 }
15996
15997 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint64_t e) {
15998         void* e_ptr = untag_ptr(e);
15999         CHECK_ACCESS(e_ptr);
16000         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
16001         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
16002         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16003         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
16004         return tag_ptr(ret_conv, true);
16005 }
16006
16007 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint64_t o) {
16008         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(o);
16009         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
16010         return ret_conv;
16011 }
16012
16013 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint64_t _res) {
16014         if (!ptr_is_owned(_res)) return;
16015         void* _res_ptr = untag_ptr(_res);
16016         CHECK_ACCESS(_res_ptr);
16017         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
16018         FREE(untag_ptr(_res));
16019         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
16020 }
16021
16022 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
16023         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16024         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
16025         return tag_ptr(ret_conv, true);
16026 }
16027 int64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint64_t arg) {
16028         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(arg);
16029         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
16030         return ret_conv;
16031 }
16032
16033 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint64_t orig) {
16034         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(orig);
16035         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16036         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
16037         return tag_ptr(ret_conv, true);
16038 }
16039
16040 void  __attribute__((export_name("TS_CVec_ThirtyTwoBytesZ_free"))) TS_CVec_ThirtyTwoBytesZ_free(ptrArray _res) {
16041         LDKCVec_ThirtyTwoBytesZ _res_constr;
16042         _res_constr.datalen = _res->arr_len;
16043         if (_res_constr.datalen > 0)
16044                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
16045         else
16046                 _res_constr.data = NULL;
16047         int8_tArray* _res_vals = (void*) _res->elems;
16048         for (size_t m = 0; m < _res_constr.datalen; m++) {
16049                 int8_tArray _res_conv_12 = _res_vals[m];
16050                 LDKThirtyTwoBytes _res_conv_12_ref;
16051                 CHECK(_res_conv_12->arr_len == 32);
16052                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
16053                 _res_constr.data[m] = _res_conv_12_ref;
16054         }
16055         FREE(_res);
16056         CVec_ThirtyTwoBytesZ_free(_res_constr);
16057 }
16058
16059 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
16060         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16061         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
16062         return tag_ptr(ret_conv, true);
16063 }
16064 int64_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint64_t arg) {
16065         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(arg);
16066         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
16067         return ret_conv;
16068 }
16069
16070 uint64_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint64_t orig) {
16071         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(orig);
16072         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16073         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
16074         return tag_ptr(ret_conv, true);
16075 }
16076
16077 uint64_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
16078         LDKThirtyTwoBytes a_ref;
16079         CHECK(a->arr_len == 32);
16080         memcpy(a_ref.data, a->elems, 32); FREE(a);
16081         LDKThirtyTwoBytes b_ref;
16082         CHECK(b->arr_len == 32);
16083         memcpy(b_ref.data, b->elems, 32); FREE(b);
16084         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16085         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
16086         return tag_ptr(ret_conv, true);
16087 }
16088
16089 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint64_t _res) {
16090         if (!ptr_is_owned(_res)) return;
16091         void* _res_ptr = untag_ptr(_res);
16092         CHECK_ACCESS(_res_ptr);
16093         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
16094         FREE(untag_ptr(_res));
16095         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
16096 }
16097
16098 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint64_t o) {
16099         void* o_ptr = untag_ptr(o);
16100         CHECK_ACCESS(o_ptr);
16101         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16102         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
16103         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16104         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
16105         return tag_ptr(ret_conv, true);
16106 }
16107
16108 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
16109         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16110         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
16111         return tag_ptr(ret_conv, true);
16112 }
16113
16114 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint64_t o) {
16115         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(o);
16116         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
16117         return ret_conv;
16118 }
16119
16120 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint64_t _res) {
16121         if (!ptr_is_owned(_res)) return;
16122         void* _res_ptr = untag_ptr(_res);
16123         CHECK_ACCESS(_res_ptr);
16124         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
16125         FREE(untag_ptr(_res));
16126         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
16127 }
16128
16129 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
16130         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16131         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
16132         return tag_ptr(ret_conv, true);
16133 }
16134 int64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint64_t arg) {
16135         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(arg);
16136         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
16137         return ret_conv;
16138 }
16139
16140 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint64_t orig) {
16141         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(orig);
16142         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16143         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
16144         return tag_ptr(ret_conv, true);
16145 }
16146
16147 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint64_t o) {
16148         void* o_ptr = untag_ptr(o);
16149         CHECK_ACCESS(o_ptr);
16150         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16151         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
16152         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16153         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
16154         return tag_ptr(ret_conv, true);
16155 }
16156
16157 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint64_t e) {
16158         void* e_ptr = untag_ptr(e);
16159         CHECK_ACCESS(e_ptr);
16160         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16161         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
16162         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16163         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
16164         return tag_ptr(ret_conv, true);
16165 }
16166
16167 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint64_t o) {
16168         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(o);
16169         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
16170         return ret_conv;
16171 }
16172
16173 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint64_t _res) {
16174         if (!ptr_is_owned(_res)) return;
16175         void* _res_ptr = untag_ptr(_res);
16176         CHECK_ACCESS(_res_ptr);
16177         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
16178         FREE(untag_ptr(_res));
16179         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
16180 }
16181
16182 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
16183         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16184         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
16185         return tag_ptr(ret_conv, true);
16186 }
16187 int64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint64_t arg) {
16188         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(arg);
16189         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
16190         return ret_conv;
16191 }
16192
16193 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint64_t orig) {
16194         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(orig);
16195         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16196         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
16197         return tag_ptr(ret_conv, true);
16198 }
16199
16200 uint64_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
16201         LDKThirtyTwoBytes o_ref;
16202         CHECK(o->arr_len == 32);
16203         memcpy(o_ref.data, o->elems, 32); FREE(o);
16204         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16205         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
16206         return tag_ptr(ret_conv, true);
16207 }
16208
16209 uint64_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
16210         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16211         *ret_conv = CResult_PaymentSecretNoneZ_err();
16212         return tag_ptr(ret_conv, true);
16213 }
16214
16215 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint64_t o) {
16216         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(o);
16217         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
16218         return ret_conv;
16219 }
16220
16221 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint64_t _res) {
16222         if (!ptr_is_owned(_res)) return;
16223         void* _res_ptr = untag_ptr(_res);
16224         CHECK_ACCESS(_res_ptr);
16225         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
16226         FREE(untag_ptr(_res));
16227         CResult_PaymentSecretNoneZ_free(_res_conv);
16228 }
16229
16230 static inline uint64_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
16231         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16232         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
16233         return tag_ptr(ret_conv, true);
16234 }
16235 int64_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint64_t arg) {
16236         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(arg);
16237         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
16238         return ret_conv;
16239 }
16240
16241 uint64_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint64_t orig) {
16242         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(orig);
16243         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16244         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
16245         return tag_ptr(ret_conv, true);
16246 }
16247
16248 uint64_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
16249         LDKThirtyTwoBytes o_ref;
16250         CHECK(o->arr_len == 32);
16251         memcpy(o_ref.data, o->elems, 32); FREE(o);
16252         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16253         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
16254         return tag_ptr(ret_conv, true);
16255 }
16256
16257 uint64_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint64_t e) {
16258         void* e_ptr = untag_ptr(e);
16259         CHECK_ACCESS(e_ptr);
16260         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16261         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
16262         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16263         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
16264         return tag_ptr(ret_conv, true);
16265 }
16266
16267 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint64_t o) {
16268         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(o);
16269         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
16270         return ret_conv;
16271 }
16272
16273 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint64_t _res) {
16274         if (!ptr_is_owned(_res)) return;
16275         void* _res_ptr = untag_ptr(_res);
16276         CHECK_ACCESS(_res_ptr);
16277         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
16278         FREE(untag_ptr(_res));
16279         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
16280 }
16281
16282 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
16283         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16284         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
16285         return tag_ptr(ret_conv, true);
16286 }
16287 int64_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint64_t arg) {
16288         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(arg);
16289         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
16290         return ret_conv;
16291 }
16292
16293 uint64_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint64_t orig) {
16294         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(orig);
16295         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16296         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
16297         return tag_ptr(ret_conv, true);
16298 }
16299
16300 uint64_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
16301         LDKThirtyTwoBytes o_ref;
16302         CHECK(o->arr_len == 32);
16303         memcpy(o_ref.data, o->elems, 32); FREE(o);
16304         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16305         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
16306         return tag_ptr(ret_conv, true);
16307 }
16308
16309 uint64_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint64_t e) {
16310         void* e_ptr = untag_ptr(e);
16311         CHECK_ACCESS(e_ptr);
16312         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16313         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
16314         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16315         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
16316         return tag_ptr(ret_conv, true);
16317 }
16318
16319 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint64_t o) {
16320         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(o);
16321         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
16322         return ret_conv;
16323 }
16324
16325 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint64_t _res) {
16326         if (!ptr_is_owned(_res)) return;
16327         void* _res_ptr = untag_ptr(_res);
16328         CHECK_ACCESS(_res_ptr);
16329         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
16330         FREE(untag_ptr(_res));
16331         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
16332 }
16333
16334 static inline uint64_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
16335         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16336         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
16337         return tag_ptr(ret_conv, true);
16338 }
16339 int64_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint64_t arg) {
16340         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(arg);
16341         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
16342         return ret_conv;
16343 }
16344
16345 uint64_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint64_t orig) {
16346         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(orig);
16347         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16348         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
16349         return tag_ptr(ret_conv, true);
16350 }
16351
16352 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(uint64_t o) {
16353         LDKCounterpartyForwardingInfo o_conv;
16354         o_conv.inner = untag_ptr(o);
16355         o_conv.is_owned = ptr_is_owned(o);
16356         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16357         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
16358         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16359         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
16360         return tag_ptr(ret_conv, true);
16361 }
16362
16363 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(uint64_t e) {
16364         LDKDecodeError e_conv;
16365         e_conv.inner = untag_ptr(e);
16366         e_conv.is_owned = ptr_is_owned(e);
16367         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16368         e_conv = DecodeError_clone(&e_conv);
16369         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16370         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
16371         return tag_ptr(ret_conv, true);
16372 }
16373
16374 jboolean  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(uint64_t o) {
16375         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(o);
16376         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
16377         return ret_conv;
16378 }
16379
16380 void  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(uint64_t _res) {
16381         if (!ptr_is_owned(_res)) return;
16382         void* _res_ptr = untag_ptr(_res);
16383         CHECK_ACCESS(_res_ptr);
16384         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
16385         FREE(untag_ptr(_res));
16386         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
16387 }
16388
16389 static inline uint64_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
16390         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16391         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
16392         return tag_ptr(ret_conv, true);
16393 }
16394 int64_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(uint64_t arg) {
16395         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(arg);
16396         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
16397         return ret_conv;
16398 }
16399
16400 uint64_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(uint64_t orig) {
16401         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(orig);
16402         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16403         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
16404         return tag_ptr(ret_conv, true);
16405 }
16406
16407 uint64_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_ok(uint64_t o) {
16408         LDKChannelCounterparty o_conv;
16409         o_conv.inner = untag_ptr(o);
16410         o_conv.is_owned = ptr_is_owned(o);
16411         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16412         o_conv = ChannelCounterparty_clone(&o_conv);
16413         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16414         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
16415         return tag_ptr(ret_conv, true);
16416 }
16417
16418 uint64_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_err(uint64_t e) {
16419         LDKDecodeError e_conv;
16420         e_conv.inner = untag_ptr(e);
16421         e_conv.is_owned = ptr_is_owned(e);
16422         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16423         e_conv = DecodeError_clone(&e_conv);
16424         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16425         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
16426         return tag_ptr(ret_conv, true);
16427 }
16428
16429 jboolean  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(uint64_t o) {
16430         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(o);
16431         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
16432         return ret_conv;
16433 }
16434
16435 void  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_free"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_free(uint64_t _res) {
16436         if (!ptr_is_owned(_res)) return;
16437         void* _res_ptr = untag_ptr(_res);
16438         CHECK_ACCESS(_res_ptr);
16439         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
16440         FREE(untag_ptr(_res));
16441         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
16442 }
16443
16444 static inline uint64_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
16445         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16446         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
16447         return tag_ptr(ret_conv, true);
16448 }
16449 int64_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(uint64_t arg) {
16450         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(arg);
16451         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
16452         return ret_conv;
16453 }
16454
16455 uint64_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone(uint64_t orig) {
16456         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(orig);
16457         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16458         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
16459         return tag_ptr(ret_conv, true);
16460 }
16461
16462 uint64_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_ok(uint64_t o) {
16463         LDKChannelDetails o_conv;
16464         o_conv.inner = untag_ptr(o);
16465         o_conv.is_owned = ptr_is_owned(o);
16466         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16467         o_conv = ChannelDetails_clone(&o_conv);
16468         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16469         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
16470         return tag_ptr(ret_conv, true);
16471 }
16472
16473 uint64_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_err(uint64_t e) {
16474         LDKDecodeError e_conv;
16475         e_conv.inner = untag_ptr(e);
16476         e_conv.is_owned = ptr_is_owned(e);
16477         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16478         e_conv = DecodeError_clone(&e_conv);
16479         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16480         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
16481         return tag_ptr(ret_conv, true);
16482 }
16483
16484 jboolean  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_is_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_is_ok(uint64_t o) {
16485         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(o);
16486         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
16487         return ret_conv;
16488 }
16489
16490 void  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_free"))) TS_CResult_ChannelDetailsDecodeErrorZ_free(uint64_t _res) {
16491         if (!ptr_is_owned(_res)) return;
16492         void* _res_ptr = untag_ptr(_res);
16493         CHECK_ACCESS(_res_ptr);
16494         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
16495         FREE(untag_ptr(_res));
16496         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
16497 }
16498
16499 static inline uint64_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
16500         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16501         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
16502         return tag_ptr(ret_conv, true);
16503 }
16504 int64_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(uint64_t arg) {
16505         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(arg);
16506         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
16507         return ret_conv;
16508 }
16509
16510 uint64_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone(uint64_t orig) {
16511         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(orig);
16512         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16513         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
16514         return tag_ptr(ret_conv, true);
16515 }
16516
16517 uint64_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_ok(uint64_t o) {
16518         LDKPhantomRouteHints o_conv;
16519         o_conv.inner = untag_ptr(o);
16520         o_conv.is_owned = ptr_is_owned(o);
16521         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16522         o_conv = PhantomRouteHints_clone(&o_conv);
16523         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16524         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
16525         return tag_ptr(ret_conv, true);
16526 }
16527
16528 uint64_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_err(uint64_t e) {
16529         LDKDecodeError e_conv;
16530         e_conv.inner = untag_ptr(e);
16531         e_conv.is_owned = ptr_is_owned(e);
16532         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16533         e_conv = DecodeError_clone(&e_conv);
16534         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16535         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
16536         return tag_ptr(ret_conv, true);
16537 }
16538
16539 jboolean  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(uint64_t o) {
16540         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(o);
16541         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
16542         return ret_conv;
16543 }
16544
16545 void  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_free"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_free(uint64_t _res) {
16546         if (!ptr_is_owned(_res)) return;
16547         void* _res_ptr = untag_ptr(_res);
16548         CHECK_ACCESS(_res_ptr);
16549         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
16550         FREE(untag_ptr(_res));
16551         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
16552 }
16553
16554 static inline uint64_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
16555         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16556         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
16557         return tag_ptr(ret_conv, true);
16558 }
16559 int64_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(uint64_t arg) {
16560         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(arg);
16561         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
16562         return ret_conv;
16563 }
16564
16565 uint64_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone(uint64_t orig) {
16566         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(orig);
16567         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16568         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
16569         return tag_ptr(ret_conv, true);
16570 }
16571
16572 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint64_tArray _res) {
16573         LDKCVec_ChannelMonitorZ _res_constr;
16574         _res_constr.datalen = _res->arr_len;
16575         if (_res_constr.datalen > 0)
16576                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16577         else
16578                 _res_constr.data = NULL;
16579         uint64_t* _res_vals = _res->elems;
16580         for (size_t q = 0; q < _res_constr.datalen; q++) {
16581                 uint64_t _res_conv_16 = _res_vals[q];
16582                 LDKChannelMonitor _res_conv_16_conv;
16583                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
16584                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
16585                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16586                 _res_constr.data[q] = _res_conv_16_conv;
16587         }
16588         FREE(_res);
16589         CVec_ChannelMonitorZ_free(_res_constr);
16590 }
16591
16592 uint64_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint64_t b) {
16593         LDKThirtyTwoBytes a_ref;
16594         CHECK(a->arr_len == 32);
16595         memcpy(a_ref.data, a->elems, 32); FREE(a);
16596         LDKChannelManager b_conv;
16597         b_conv.inner = untag_ptr(b);
16598         b_conv.is_owned = ptr_is_owned(b);
16599         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16600         // WARNING: we need a move here but no clone is available for LDKChannelManager
16601         
16602         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
16603         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
16604         return tag_ptr(ret_conv, true);
16605 }
16606
16607 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint64_t _res) {
16608         if (!ptr_is_owned(_res)) return;
16609         void* _res_ptr = untag_ptr(_res);
16610         CHECK_ACCESS(_res_ptr);
16611         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
16612         FREE(untag_ptr(_res));
16613         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
16614 }
16615
16616 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint64_t o) {
16617         void* o_ptr = untag_ptr(o);
16618         CHECK_ACCESS(o_ptr);
16619         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
16620         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
16621         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16622         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
16623         return tag_ptr(ret_conv, true);
16624 }
16625
16626 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint64_t e) {
16627         LDKDecodeError e_conv;
16628         e_conv.inner = untag_ptr(e);
16629         e_conv.is_owned = ptr_is_owned(e);
16630         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16631         e_conv = DecodeError_clone(&e_conv);
16632         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16633         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
16634         return tag_ptr(ret_conv, true);
16635 }
16636
16637 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint64_t o) {
16638         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(o);
16639         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
16640         return ret_conv;
16641 }
16642
16643 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint64_t _res) {
16644         if (!ptr_is_owned(_res)) return;
16645         void* _res_ptr = untag_ptr(_res);
16646         CHECK_ACCESS(_res_ptr);
16647         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
16648         FREE(untag_ptr(_res));
16649         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
16650 }
16651
16652 uint64_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint64_t o) {
16653         LDKChannelConfig o_conv;
16654         o_conv.inner = untag_ptr(o);
16655         o_conv.is_owned = ptr_is_owned(o);
16656         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16657         o_conv = ChannelConfig_clone(&o_conv);
16658         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16659         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
16660         return tag_ptr(ret_conv, true);
16661 }
16662
16663 uint64_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint64_t e) {
16664         LDKDecodeError e_conv;
16665         e_conv.inner = untag_ptr(e);
16666         e_conv.is_owned = ptr_is_owned(e);
16667         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16668         e_conv = DecodeError_clone(&e_conv);
16669         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16670         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
16671         return tag_ptr(ret_conv, true);
16672 }
16673
16674 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint64_t o) {
16675         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(o);
16676         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
16677         return ret_conv;
16678 }
16679
16680 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint64_t _res) {
16681         if (!ptr_is_owned(_res)) return;
16682         void* _res_ptr = untag_ptr(_res);
16683         CHECK_ACCESS(_res_ptr);
16684         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
16685         FREE(untag_ptr(_res));
16686         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
16687 }
16688
16689 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
16690         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16691         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
16692         return tag_ptr(ret_conv, true);
16693 }
16694 int64_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint64_t arg) {
16695         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(arg);
16696         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
16697         return ret_conv;
16698 }
16699
16700 uint64_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint64_t orig) {
16701         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(orig);
16702         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16703         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
16704         return tag_ptr(ret_conv, true);
16705 }
16706
16707 uint64_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint64_t o) {
16708         LDKOutPoint o_conv;
16709         o_conv.inner = untag_ptr(o);
16710         o_conv.is_owned = ptr_is_owned(o);
16711         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16712         o_conv = OutPoint_clone(&o_conv);
16713         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16714         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
16715         return tag_ptr(ret_conv, true);
16716 }
16717
16718 uint64_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint64_t e) {
16719         LDKDecodeError e_conv;
16720         e_conv.inner = untag_ptr(e);
16721         e_conv.is_owned = ptr_is_owned(e);
16722         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16723         e_conv = DecodeError_clone(&e_conv);
16724         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16725         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
16726         return tag_ptr(ret_conv, true);
16727 }
16728
16729 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint64_t o) {
16730         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(o);
16731         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
16732         return ret_conv;
16733 }
16734
16735 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint64_t _res) {
16736         if (!ptr_is_owned(_res)) return;
16737         void* _res_ptr = untag_ptr(_res);
16738         CHECK_ACCESS(_res_ptr);
16739         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
16740         FREE(untag_ptr(_res));
16741         CResult_OutPointDecodeErrorZ_free(_res_conv);
16742 }
16743
16744 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
16745         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16746         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
16747         return tag_ptr(ret_conv, true);
16748 }
16749 int64_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint64_t arg) {
16750         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(arg);
16751         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
16752         return ret_conv;
16753 }
16754
16755 uint64_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint64_t orig) {
16756         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(orig);
16757         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16758         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
16759         return tag_ptr(ret_conv, true);
16760 }
16761
16762 uint64_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint64_t o) {
16763         void* o_ptr = untag_ptr(o);
16764         CHECK_ACCESS(o_ptr);
16765         LDKType o_conv = *(LDKType*)(o_ptr);
16766         if (o_conv.free == LDKType_JCalls_free) {
16767                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16768                 LDKType_JCalls_cloned(&o_conv);
16769         }
16770         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16771         *ret_copy = COption_TypeZ_some(o_conv);
16772         uint64_t ret_ref = tag_ptr(ret_copy, true);
16773         return ret_ref;
16774 }
16775
16776 uint64_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
16777         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16778         *ret_copy = COption_TypeZ_none();
16779         uint64_t ret_ref = tag_ptr(ret_copy, true);
16780         return ret_ref;
16781 }
16782
16783 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint64_t _res) {
16784         if (!ptr_is_owned(_res)) return;
16785         void* _res_ptr = untag_ptr(_res);
16786         CHECK_ACCESS(_res_ptr);
16787         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
16788         FREE(untag_ptr(_res));
16789         COption_TypeZ_free(_res_conv);
16790 }
16791
16792 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
16793         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16794         *ret_copy = COption_TypeZ_clone(arg);
16795         uint64_t ret_ref = tag_ptr(ret_copy, true);
16796         return ret_ref;
16797 }
16798 int64_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint64_t arg) {
16799         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)untag_ptr(arg);
16800         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
16801         return ret_conv;
16802 }
16803
16804 uint64_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint64_t orig) {
16805         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)untag_ptr(orig);
16806         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16807         *ret_copy = COption_TypeZ_clone(orig_conv);
16808         uint64_t ret_ref = tag_ptr(ret_copy, true);
16809         return ret_ref;
16810 }
16811
16812 uint64_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint64_t o) {
16813         void* o_ptr = untag_ptr(o);
16814         CHECK_ACCESS(o_ptr);
16815         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
16816         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)untag_ptr(o));
16817         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16818         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
16819         return tag_ptr(ret_conv, true);
16820 }
16821
16822 uint64_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint64_t e) {
16823         LDKDecodeError e_conv;
16824         e_conv.inner = untag_ptr(e);
16825         e_conv.is_owned = ptr_is_owned(e);
16826         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16827         e_conv = DecodeError_clone(&e_conv);
16828         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16829         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
16830         return tag_ptr(ret_conv, true);
16831 }
16832
16833 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint64_t o) {
16834         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(o);
16835         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
16836         return ret_conv;
16837 }
16838
16839 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint64_t _res) {
16840         if (!ptr_is_owned(_res)) return;
16841         void* _res_ptr = untag_ptr(_res);
16842         CHECK_ACCESS(_res_ptr);
16843         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
16844         FREE(untag_ptr(_res));
16845         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
16846 }
16847
16848 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
16849         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16850         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
16851         return tag_ptr(ret_conv, true);
16852 }
16853 int64_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint64_t arg) {
16854         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(arg);
16855         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
16856         return ret_conv;
16857 }
16858
16859 uint64_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint64_t orig) {
16860         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(orig);
16861         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16862         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
16863         return tag_ptr(ret_conv, true);
16864 }
16865
16866 uint64_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_ok"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
16867         LDKThirtyTwoBytes o_ref;
16868         CHECK(o->arr_len == 32);
16869         memcpy(o_ref.data, o->elems, 32); FREE(o);
16870         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16871         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
16872         return tag_ptr(ret_conv, true);
16873 }
16874
16875 uint64_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_err"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint64_t e) {
16876         void* e_ptr = untag_ptr(e);
16877         CHECK_ACCESS(e_ptr);
16878         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
16879         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
16880         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16881         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
16882         return tag_ptr(ret_conv, true);
16883 }
16884
16885 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_is_ok"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint64_t o) {
16886         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(o);
16887         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
16888         return ret_conv;
16889 }
16890
16891 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_free"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint64_t _res) {
16892         if (!ptr_is_owned(_res)) return;
16893         void* _res_ptr = untag_ptr(_res);
16894         CHECK_ACCESS(_res_ptr);
16895         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
16896         FREE(untag_ptr(_res));
16897         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
16898 }
16899
16900 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
16901         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16902         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
16903         return tag_ptr(ret_conv, true);
16904 }
16905 int64_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone_ptr"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint64_t arg) {
16906         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(arg);
16907         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
16908         return ret_conv;
16909 }
16910
16911 uint64_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint64_t orig) {
16912         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(orig);
16913         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16914         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
16915         return tag_ptr(ret_conv, true);
16916 }
16917
16918 uint64_t  __attribute__((export_name("TS_CResult_InFlightHtlcsDecodeErrorZ_ok"))) TS_CResult_InFlightHtlcsDecodeErrorZ_ok(uint64_t o) {
16919         LDKInFlightHtlcs o_conv;
16920         o_conv.inner = untag_ptr(o);
16921         o_conv.is_owned = ptr_is_owned(o);
16922         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16923         // WARNING: we need a move here but no clone is available for LDKInFlightHtlcs
16924         
16925         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
16926         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_ok(o_conv);
16927         return tag_ptr(ret_conv, true);
16928 }
16929
16930 uint64_t  __attribute__((export_name("TS_CResult_InFlightHtlcsDecodeErrorZ_err"))) TS_CResult_InFlightHtlcsDecodeErrorZ_err(uint64_t e) {
16931         LDKDecodeError e_conv;
16932         e_conv.inner = untag_ptr(e);
16933         e_conv.is_owned = ptr_is_owned(e);
16934         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16935         e_conv = DecodeError_clone(&e_conv);
16936         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
16937         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_err(e_conv);
16938         return tag_ptr(ret_conv, true);
16939 }
16940
16941 jboolean  __attribute__((export_name("TS_CResult_InFlightHtlcsDecodeErrorZ_is_ok"))) TS_CResult_InFlightHtlcsDecodeErrorZ_is_ok(uint64_t o) {
16942         LDKCResult_InFlightHtlcsDecodeErrorZ* o_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(o);
16943         jboolean ret_conv = CResult_InFlightHtlcsDecodeErrorZ_is_ok(o_conv);
16944         return ret_conv;
16945 }
16946
16947 void  __attribute__((export_name("TS_CResult_InFlightHtlcsDecodeErrorZ_free"))) TS_CResult_InFlightHtlcsDecodeErrorZ_free(uint64_t _res) {
16948         if (!ptr_is_owned(_res)) return;
16949         void* _res_ptr = untag_ptr(_res);
16950         CHECK_ACCESS(_res_ptr);
16951         LDKCResult_InFlightHtlcsDecodeErrorZ _res_conv = *(LDKCResult_InFlightHtlcsDecodeErrorZ*)(_res_ptr);
16952         FREE(untag_ptr(_res));
16953         CResult_InFlightHtlcsDecodeErrorZ_free(_res_conv);
16954 }
16955
16956 uint64_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_ok"))) TS_CResult_SiPrefixParseErrorZ_ok(uint32_t o) {
16957         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
16958         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16959         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
16960         return tag_ptr(ret_conv, true);
16961 }
16962
16963 uint64_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_err"))) TS_CResult_SiPrefixParseErrorZ_err(uint64_t e) {
16964         void* e_ptr = untag_ptr(e);
16965         CHECK_ACCESS(e_ptr);
16966         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
16967         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
16968         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16969         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
16970         return tag_ptr(ret_conv, true);
16971 }
16972
16973 jboolean  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_is_ok"))) TS_CResult_SiPrefixParseErrorZ_is_ok(uint64_t o) {
16974         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(o);
16975         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
16976         return ret_conv;
16977 }
16978
16979 void  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_free"))) TS_CResult_SiPrefixParseErrorZ_free(uint64_t _res) {
16980         if (!ptr_is_owned(_res)) return;
16981         void* _res_ptr = untag_ptr(_res);
16982         CHECK_ACCESS(_res_ptr);
16983         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
16984         FREE(untag_ptr(_res));
16985         CResult_SiPrefixParseErrorZ_free(_res_conv);
16986 }
16987
16988 static inline uint64_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
16989         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16990         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
16991         return tag_ptr(ret_conv, true);
16992 }
16993 int64_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone_ptr"))) TS_CResult_SiPrefixParseErrorZ_clone_ptr(uint64_t arg) {
16994         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(arg);
16995         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
16996         return ret_conv;
16997 }
16998
16999 uint64_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone"))) TS_CResult_SiPrefixParseErrorZ_clone(uint64_t orig) {
17000         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(orig);
17001         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
17002         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
17003         return tag_ptr(ret_conv, true);
17004 }
17005
17006 uint64_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_ok(uint64_t o) {
17007         LDKInvoice o_conv;
17008         o_conv.inner = untag_ptr(o);
17009         o_conv.is_owned = ptr_is_owned(o);
17010         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17011         o_conv = Invoice_clone(&o_conv);
17012         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17013         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
17014         return tag_ptr(ret_conv, true);
17015 }
17016
17017 uint64_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_err(uint64_t e) {
17018         void* e_ptr = untag_ptr(e);
17019         CHECK_ACCESS(e_ptr);
17020         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
17021         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)untag_ptr(e));
17022         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17023         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
17024         return tag_ptr(ret_conv, true);
17025 }
17026
17027 jboolean  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok(uint64_t o) {
17028         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(o);
17029         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
17030         return ret_conv;
17031 }
17032
17033 void  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_free"))) TS_CResult_InvoiceParseOrSemanticErrorZ_free(uint64_t _res) {
17034         if (!ptr_is_owned(_res)) return;
17035         void* _res_ptr = untag_ptr(_res);
17036         CHECK_ACCESS(_res_ptr);
17037         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
17038         FREE(untag_ptr(_res));
17039         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
17040 }
17041
17042 static inline uint64_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
17043         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17044         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
17045         return tag_ptr(ret_conv, true);
17046 }
17047 int64_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(uint64_t arg) {
17048         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(arg);
17049         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
17050         return ret_conv;
17051 }
17052
17053 uint64_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone(uint64_t orig) {
17054         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(orig);
17055         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17056         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
17057         return tag_ptr(ret_conv, true);
17058 }
17059
17060 uint64_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_ok(uint64_t o) {
17061         LDKSignedRawInvoice o_conv;
17062         o_conv.inner = untag_ptr(o);
17063         o_conv.is_owned = ptr_is_owned(o);
17064         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17065         o_conv = SignedRawInvoice_clone(&o_conv);
17066         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17067         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
17068         return tag_ptr(ret_conv, true);
17069 }
17070
17071 uint64_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_err(uint64_t e) {
17072         void* e_ptr = untag_ptr(e);
17073         CHECK_ACCESS(e_ptr);
17074         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
17075         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
17076         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17077         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
17078         return tag_ptr(ret_conv, true);
17079 }
17080
17081 jboolean  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_is_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_is_ok(uint64_t o) {
17082         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(o);
17083         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
17084         return ret_conv;
17085 }
17086
17087 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_free"))) TS_CResult_SignedRawInvoiceParseErrorZ_free(uint64_t _res) {
17088         if (!ptr_is_owned(_res)) return;
17089         void* _res_ptr = untag_ptr(_res);
17090         CHECK_ACCESS(_res_ptr);
17091         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
17092         FREE(untag_ptr(_res));
17093         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
17094 }
17095
17096 static inline uint64_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
17097         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17098         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
17099         return tag_ptr(ret_conv, true);
17100 }
17101 int64_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr(uint64_t arg) {
17102         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(arg);
17103         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
17104         return ret_conv;
17105 }
17106
17107 uint64_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone(uint64_t orig) {
17108         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(orig);
17109         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17110         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
17111         return tag_ptr(ret_conv, true);
17112 }
17113
17114 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
17115         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17116         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
17117         return tag_ptr(ret_conv, true);
17118 }
17119 int64_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint64_t arg) {
17120         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(arg);
17121         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
17122         return ret_conv;
17123 }
17124
17125 uint64_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint64_t orig) {
17126         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(orig);
17127         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17128         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
17129         return tag_ptr(ret_conv, true);
17130 }
17131
17132 uint64_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint64_t a, int8_tArray b, uint64_t c) {
17133         LDKRawInvoice a_conv;
17134         a_conv.inner = untag_ptr(a);
17135         a_conv.is_owned = ptr_is_owned(a);
17136         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17137         a_conv = RawInvoice_clone(&a_conv);
17138         LDKThirtyTwoBytes b_ref;
17139         CHECK(b->arr_len == 32);
17140         memcpy(b_ref.data, b->elems, 32); FREE(b);
17141         LDKInvoiceSignature c_conv;
17142         c_conv.inner = untag_ptr(c);
17143         c_conv.is_owned = ptr_is_owned(c);
17144         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
17145         c_conv = InvoiceSignature_clone(&c_conv);
17146         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17147         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
17148         return tag_ptr(ret_conv, true);
17149 }
17150
17151 void  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint64_t _res) {
17152         if (!ptr_is_owned(_res)) return;
17153         void* _res_ptr = untag_ptr(_res);
17154         CHECK_ACCESS(_res_ptr);
17155         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
17156         FREE(untag_ptr(_res));
17157         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
17158 }
17159
17160 uint64_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_ok"))) TS_CResult_PayeePubKeyErrorZ_ok(uint64_t o) {
17161         LDKPayeePubKey o_conv;
17162         o_conv.inner = untag_ptr(o);
17163         o_conv.is_owned = ptr_is_owned(o);
17164         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17165         o_conv = PayeePubKey_clone(&o_conv);
17166         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17167         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
17168         return tag_ptr(ret_conv, true);
17169 }
17170
17171 uint64_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_err"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
17172         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
17173         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17174         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
17175         return tag_ptr(ret_conv, true);
17176 }
17177
17178 jboolean  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_is_ok"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint64_t o) {
17179         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(o);
17180         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
17181         return ret_conv;
17182 }
17183
17184 void  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_free"))) TS_CResult_PayeePubKeyErrorZ_free(uint64_t _res) {
17185         if (!ptr_is_owned(_res)) return;
17186         void* _res_ptr = untag_ptr(_res);
17187         CHECK_ACCESS(_res_ptr);
17188         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
17189         FREE(untag_ptr(_res));
17190         CResult_PayeePubKeyErrorZ_free(_res_conv);
17191 }
17192
17193 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
17194         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17195         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
17196         return tag_ptr(ret_conv, true);
17197 }
17198 int64_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone_ptr"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint64_t arg) {
17199         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(arg);
17200         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
17201         return ret_conv;
17202 }
17203
17204 uint64_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone"))) TS_CResult_PayeePubKeyErrorZ_clone(uint64_t orig) {
17205         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(orig);
17206         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17207         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
17208         return tag_ptr(ret_conv, true);
17209 }
17210
17211 void  __attribute__((export_name("TS_CVec_PrivateRouteZ_free"))) TS_CVec_PrivateRouteZ_free(uint64_tArray _res) {
17212         LDKCVec_PrivateRouteZ _res_constr;
17213         _res_constr.datalen = _res->arr_len;
17214         if (_res_constr.datalen > 0)
17215                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
17216         else
17217                 _res_constr.data = NULL;
17218         uint64_t* _res_vals = _res->elems;
17219         for (size_t o = 0; o < _res_constr.datalen; o++) {
17220                 uint64_t _res_conv_14 = _res_vals[o];
17221                 LDKPrivateRoute _res_conv_14_conv;
17222                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
17223                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
17224                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
17225                 _res_constr.data[o] = _res_conv_14_conv;
17226         }
17227         FREE(_res);
17228         CVec_PrivateRouteZ_free(_res_constr);
17229 }
17230
17231 uint64_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint64_t o) {
17232         LDKPositiveTimestamp o_conv;
17233         o_conv.inner = untag_ptr(o);
17234         o_conv.is_owned = ptr_is_owned(o);
17235         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17236         o_conv = PositiveTimestamp_clone(&o_conv);
17237         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17238         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
17239         return tag_ptr(ret_conv, true);
17240 }
17241
17242 uint64_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_err"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
17243         LDKCreationError e_conv = LDKCreationError_from_js(e);
17244         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17245         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
17246         return tag_ptr(ret_conv, true);
17247 }
17248
17249 jboolean  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_is_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint64_t o) {
17250         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(o);
17251         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
17252         return ret_conv;
17253 }
17254
17255 void  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_free"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint64_t _res) {
17256         if (!ptr_is_owned(_res)) return;
17257         void* _res_ptr = untag_ptr(_res);
17258         CHECK_ACCESS(_res_ptr);
17259         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
17260         FREE(untag_ptr(_res));
17261         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
17262 }
17263
17264 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
17265         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17266         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
17267         return tag_ptr(ret_conv, true);
17268 }
17269 int64_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint64_t arg) {
17270         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(arg);
17271         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
17272         return ret_conv;
17273 }
17274
17275 uint64_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint64_t orig) {
17276         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(orig);
17277         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17278         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
17279         return tag_ptr(ret_conv, true);
17280 }
17281
17282 uint64_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_ok"))) TS_CResult_NoneSemanticErrorZ_ok() {
17283         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17284         *ret_conv = CResult_NoneSemanticErrorZ_ok();
17285         return tag_ptr(ret_conv, true);
17286 }
17287
17288 uint64_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_err"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
17289         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
17290         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17291         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
17292         return tag_ptr(ret_conv, true);
17293 }
17294
17295 jboolean  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_is_ok"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint64_t o) {
17296         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(o);
17297         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
17298         return ret_conv;
17299 }
17300
17301 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_free"))) TS_CResult_NoneSemanticErrorZ_free(uint64_t _res) {
17302         if (!ptr_is_owned(_res)) return;
17303         void* _res_ptr = untag_ptr(_res);
17304         CHECK_ACCESS(_res_ptr);
17305         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
17306         FREE(untag_ptr(_res));
17307         CResult_NoneSemanticErrorZ_free(_res_conv);
17308 }
17309
17310 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
17311         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17312         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
17313         return tag_ptr(ret_conv, true);
17314 }
17315 int64_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone_ptr"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint64_t arg) {
17316         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(arg);
17317         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
17318         return ret_conv;
17319 }
17320
17321 uint64_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone"))) TS_CResult_NoneSemanticErrorZ_clone(uint64_t orig) {
17322         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(orig);
17323         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17324         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
17325         return tag_ptr(ret_conv, true);
17326 }
17327
17328 uint64_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_ok"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint64_t o) {
17329         LDKInvoice o_conv;
17330         o_conv.inner = untag_ptr(o);
17331         o_conv.is_owned = ptr_is_owned(o);
17332         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17333         o_conv = Invoice_clone(&o_conv);
17334         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17335         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
17336         return tag_ptr(ret_conv, true);
17337 }
17338
17339 uint64_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_err"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
17340         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
17341         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17342         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
17343         return tag_ptr(ret_conv, true);
17344 }
17345
17346 jboolean  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_is_ok"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint64_t o) {
17347         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(o);
17348         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
17349         return ret_conv;
17350 }
17351
17352 void  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_free"))) TS_CResult_InvoiceSemanticErrorZ_free(uint64_t _res) {
17353         if (!ptr_is_owned(_res)) return;
17354         void* _res_ptr = untag_ptr(_res);
17355         CHECK_ACCESS(_res_ptr);
17356         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
17357         FREE(untag_ptr(_res));
17358         CResult_InvoiceSemanticErrorZ_free(_res_conv);
17359 }
17360
17361 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
17362         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17363         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
17364         return tag_ptr(ret_conv, true);
17365 }
17366 int64_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint64_t arg) {
17367         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(arg);
17368         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
17369         return ret_conv;
17370 }
17371
17372 uint64_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint64_t orig) {
17373         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(orig);
17374         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17375         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
17376         return tag_ptr(ret_conv, true);
17377 }
17378
17379 uint64_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_ok"))) TS_CResult_DescriptionCreationErrorZ_ok(uint64_t o) {
17380         LDKDescription o_conv;
17381         o_conv.inner = untag_ptr(o);
17382         o_conv.is_owned = ptr_is_owned(o);
17383         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17384         o_conv = Description_clone(&o_conv);
17385         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17386         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
17387         return tag_ptr(ret_conv, true);
17388 }
17389
17390 uint64_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_err"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
17391         LDKCreationError e_conv = LDKCreationError_from_js(e);
17392         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17393         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
17394         return tag_ptr(ret_conv, true);
17395 }
17396
17397 jboolean  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_is_ok"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint64_t o) {
17398         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(o);
17399         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
17400         return ret_conv;
17401 }
17402
17403 void  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_free"))) TS_CResult_DescriptionCreationErrorZ_free(uint64_t _res) {
17404         if (!ptr_is_owned(_res)) return;
17405         void* _res_ptr = untag_ptr(_res);
17406         CHECK_ACCESS(_res_ptr);
17407         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
17408         FREE(untag_ptr(_res));
17409         CResult_DescriptionCreationErrorZ_free(_res_conv);
17410 }
17411
17412 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
17413         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17414         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
17415         return tag_ptr(ret_conv, true);
17416 }
17417 int64_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone_ptr"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint64_t arg) {
17418         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(arg);
17419         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
17420         return ret_conv;
17421 }
17422
17423 uint64_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone"))) TS_CResult_DescriptionCreationErrorZ_clone(uint64_t orig) {
17424         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(orig);
17425         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17426         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
17427         return tag_ptr(ret_conv, true);
17428 }
17429
17430 uint64_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_ok"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint64_t o) {
17431         LDKPrivateRoute o_conv;
17432         o_conv.inner = untag_ptr(o);
17433         o_conv.is_owned = ptr_is_owned(o);
17434         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17435         o_conv = PrivateRoute_clone(&o_conv);
17436         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17437         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
17438         return tag_ptr(ret_conv, true);
17439 }
17440
17441 uint64_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_err"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
17442         LDKCreationError e_conv = LDKCreationError_from_js(e);
17443         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17444         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
17445         return tag_ptr(ret_conv, true);
17446 }
17447
17448 jboolean  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_is_ok"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint64_t o) {
17449         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(o);
17450         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
17451         return ret_conv;
17452 }
17453
17454 void  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_free"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint64_t _res) {
17455         if (!ptr_is_owned(_res)) return;
17456         void* _res_ptr = untag_ptr(_res);
17457         CHECK_ACCESS(_res_ptr);
17458         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
17459         FREE(untag_ptr(_res));
17460         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
17461 }
17462
17463 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
17464         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17465         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
17466         return tag_ptr(ret_conv, true);
17467 }
17468 int64_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone_ptr"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint64_t arg) {
17469         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(arg);
17470         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
17471         return ret_conv;
17472 }
17473
17474 uint64_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint64_t orig) {
17475         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(orig);
17476         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17477         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
17478         return tag_ptr(ret_conv, true);
17479 }
17480
17481 uint64_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
17482         LDKStr o_conv = str_ref_to_owned_c(o);
17483         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17484         *ret_conv = CResult_StringErrorZ_ok(o_conv);
17485         return tag_ptr(ret_conv, true);
17486 }
17487
17488 uint64_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
17489         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
17490         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17491         *ret_conv = CResult_StringErrorZ_err(e_conv);
17492         return tag_ptr(ret_conv, true);
17493 }
17494
17495 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint64_t o) {
17496         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)untag_ptr(o);
17497         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
17498         return ret_conv;
17499 }
17500
17501 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint64_t _res) {
17502         if (!ptr_is_owned(_res)) return;
17503         void* _res_ptr = untag_ptr(_res);
17504         CHECK_ACCESS(_res_ptr);
17505         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
17506         FREE(untag_ptr(_res));
17507         CResult_StringErrorZ_free(_res_conv);
17508 }
17509
17510 static inline uint64_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
17511         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17512         *ret_conv = CResult_StringErrorZ_clone(arg);
17513         return tag_ptr(ret_conv, true);
17514 }
17515 int64_t  __attribute__((export_name("TS_CResult_StringErrorZ_clone_ptr"))) TS_CResult_StringErrorZ_clone_ptr(uint64_t arg) {
17516         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)untag_ptr(arg);
17517         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
17518         return ret_conv;
17519 }
17520
17521 uint64_t  __attribute__((export_name("TS_CResult_StringErrorZ_clone"))) TS_CResult_StringErrorZ_clone(uint64_t orig) {
17522         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)untag_ptr(orig);
17523         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17524         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
17525         return tag_ptr(ret_conv, true);
17526 }
17527
17528 uint64_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint64_t o) {
17529         LDKChannelMonitorUpdate o_conv;
17530         o_conv.inner = untag_ptr(o);
17531         o_conv.is_owned = ptr_is_owned(o);
17532         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17533         o_conv = ChannelMonitorUpdate_clone(&o_conv);
17534         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17535         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
17536         return tag_ptr(ret_conv, true);
17537 }
17538
17539 uint64_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint64_t e) {
17540         LDKDecodeError e_conv;
17541         e_conv.inner = untag_ptr(e);
17542         e_conv.is_owned = ptr_is_owned(e);
17543         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17544         e_conv = DecodeError_clone(&e_conv);
17545         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17546         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
17547         return tag_ptr(ret_conv, true);
17548 }
17549
17550 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint64_t o) {
17551         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(o);
17552         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
17553         return ret_conv;
17554 }
17555
17556 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint64_t _res) {
17557         if (!ptr_is_owned(_res)) return;
17558         void* _res_ptr = untag_ptr(_res);
17559         CHECK_ACCESS(_res_ptr);
17560         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
17561         FREE(untag_ptr(_res));
17562         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
17563 }
17564
17565 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
17566         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17567         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
17568         return tag_ptr(ret_conv, true);
17569 }
17570 int64_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint64_t arg) {
17571         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(arg);
17572         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
17573         return ret_conv;
17574 }
17575
17576 uint64_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint64_t orig) {
17577         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(orig);
17578         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17579         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
17580         return tag_ptr(ret_conv, true);
17581 }
17582
17583 uint64_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint64_t o) {
17584         void* o_ptr = untag_ptr(o);
17585         CHECK_ACCESS(o_ptr);
17586         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
17587         o_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(o));
17588         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17589         *ret_copy = COption_MonitorEventZ_some(o_conv);
17590         uint64_t ret_ref = tag_ptr(ret_copy, true);
17591         return ret_ref;
17592 }
17593
17594 uint64_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
17595         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17596         *ret_copy = COption_MonitorEventZ_none();
17597         uint64_t ret_ref = tag_ptr(ret_copy, true);
17598         return ret_ref;
17599 }
17600
17601 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint64_t _res) {
17602         if (!ptr_is_owned(_res)) return;
17603         void* _res_ptr = untag_ptr(_res);
17604         CHECK_ACCESS(_res_ptr);
17605         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
17606         FREE(untag_ptr(_res));
17607         COption_MonitorEventZ_free(_res_conv);
17608 }
17609
17610 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
17611         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17612         *ret_copy = COption_MonitorEventZ_clone(arg);
17613         uint64_t ret_ref = tag_ptr(ret_copy, true);
17614         return ret_ref;
17615 }
17616 int64_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint64_t arg) {
17617         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)untag_ptr(arg);
17618         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
17619         return ret_conv;
17620 }
17621
17622 uint64_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint64_t orig) {
17623         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)untag_ptr(orig);
17624         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17625         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
17626         uint64_t ret_ref = tag_ptr(ret_copy, true);
17627         return ret_ref;
17628 }
17629
17630 uint64_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint64_t o) {
17631         void* o_ptr = untag_ptr(o);
17632         CHECK_ACCESS(o_ptr);
17633         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
17634         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)untag_ptr(o));
17635         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17636         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
17637         return tag_ptr(ret_conv, true);
17638 }
17639
17640 uint64_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint64_t e) {
17641         LDKDecodeError e_conv;
17642         e_conv.inner = untag_ptr(e);
17643         e_conv.is_owned = ptr_is_owned(e);
17644         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17645         e_conv = DecodeError_clone(&e_conv);
17646         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17647         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
17648         return tag_ptr(ret_conv, true);
17649 }
17650
17651 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint64_t o) {
17652         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(o);
17653         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
17654         return ret_conv;
17655 }
17656
17657 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint64_t _res) {
17658         if (!ptr_is_owned(_res)) return;
17659         void* _res_ptr = untag_ptr(_res);
17660         CHECK_ACCESS(_res_ptr);
17661         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
17662         FREE(untag_ptr(_res));
17663         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
17664 }
17665
17666 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
17667         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17668         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
17669         return tag_ptr(ret_conv, true);
17670 }
17671 int64_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint64_t arg) {
17672         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(arg);
17673         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
17674         return ret_conv;
17675 }
17676
17677 uint64_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint64_t orig) {
17678         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(orig);
17679         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17680         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
17681         return tag_ptr(ret_conv, true);
17682 }
17683
17684 uint64_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint64_t o) {
17685         LDKHTLCUpdate o_conv;
17686         o_conv.inner = untag_ptr(o);
17687         o_conv.is_owned = ptr_is_owned(o);
17688         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17689         o_conv = HTLCUpdate_clone(&o_conv);
17690         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17691         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
17692         return tag_ptr(ret_conv, true);
17693 }
17694
17695 uint64_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint64_t e) {
17696         LDKDecodeError e_conv;
17697         e_conv.inner = untag_ptr(e);
17698         e_conv.is_owned = ptr_is_owned(e);
17699         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17700         e_conv = DecodeError_clone(&e_conv);
17701         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17702         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
17703         return tag_ptr(ret_conv, true);
17704 }
17705
17706 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint64_t o) {
17707         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(o);
17708         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
17709         return ret_conv;
17710 }
17711
17712 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint64_t _res) {
17713         if (!ptr_is_owned(_res)) return;
17714         void* _res_ptr = untag_ptr(_res);
17715         CHECK_ACCESS(_res_ptr);
17716         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
17717         FREE(untag_ptr(_res));
17718         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
17719 }
17720
17721 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
17722         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17723         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
17724         return tag_ptr(ret_conv, true);
17725 }
17726 int64_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint64_t arg) {
17727         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(arg);
17728         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
17729         return ret_conv;
17730 }
17731
17732 uint64_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint64_t orig) {
17733         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(orig);
17734         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17735         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
17736         return tag_ptr(ret_conv, true);
17737 }
17738
17739 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
17740         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17741         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
17742         return tag_ptr(ret_conv, true);
17743 }
17744 int64_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone_ptr"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint64_t arg) {
17745         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(arg);
17746         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
17747         return ret_conv;
17748 }
17749
17750 uint64_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone"))) TS_C2Tuple_OutPointScriptZ_clone(uint64_t orig) {
17751         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(orig);
17752         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17753         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
17754         return tag_ptr(ret_conv, true);
17755 }
17756
17757 uint64_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint64_t a, int8_tArray b) {
17758         LDKOutPoint a_conv;
17759         a_conv.inner = untag_ptr(a);
17760         a_conv.is_owned = ptr_is_owned(a);
17761         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17762         a_conv = OutPoint_clone(&a_conv);
17763         LDKCVec_u8Z b_ref;
17764         b_ref.datalen = b->arr_len;
17765         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
17766         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
17767         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17768         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
17769         return tag_ptr(ret_conv, true);
17770 }
17771
17772 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint64_t _res) {
17773         if (!ptr_is_owned(_res)) return;
17774         void* _res_ptr = untag_ptr(_res);
17775         CHECK_ACCESS(_res_ptr);
17776         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
17777         FREE(untag_ptr(_res));
17778         C2Tuple_OutPointScriptZ_free(_res_conv);
17779 }
17780
17781 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
17782         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17783         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
17784         return tag_ptr(ret_conv, true);
17785 }
17786 int64_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone_ptr"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint64_t arg) {
17787         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(arg);
17788         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
17789         return ret_conv;
17790 }
17791
17792 uint64_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone"))) TS_C2Tuple_u32ScriptZ_clone(uint64_t orig) {
17793         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(orig);
17794         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17795         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
17796         return tag_ptr(ret_conv, true);
17797 }
17798
17799 uint64_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
17800         LDKCVec_u8Z b_ref;
17801         b_ref.datalen = b->arr_len;
17802         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
17803         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
17804         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17805         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
17806         return tag_ptr(ret_conv, true);
17807 }
17808
17809 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint64_t _res) {
17810         if (!ptr_is_owned(_res)) return;
17811         void* _res_ptr = untag_ptr(_res);
17812         CHECK_ACCESS(_res_ptr);
17813         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
17814         FREE(untag_ptr(_res));
17815         C2Tuple_u32ScriptZ_free(_res_conv);
17816 }
17817
17818 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint64_tArray _res) {
17819         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
17820         _res_constr.datalen = _res->arr_len;
17821         if (_res_constr.datalen > 0)
17822                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
17823         else
17824                 _res_constr.data = NULL;
17825         uint64_t* _res_vals = _res->elems;
17826         for (size_t v = 0; v < _res_constr.datalen; v++) {
17827                 uint64_t _res_conv_21 = _res_vals[v];
17828                 void* _res_conv_21_ptr = untag_ptr(_res_conv_21);
17829                 CHECK_ACCESS(_res_conv_21_ptr);
17830                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
17831                 FREE(untag_ptr(_res_conv_21));
17832                 _res_constr.data[v] = _res_conv_21_conv;
17833         }
17834         FREE(_res);
17835         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
17836 }
17837
17838 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
17839         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17840         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
17841         return tag_ptr(ret_conv, true);
17842 }
17843 int64_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint64_t arg) {
17844         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(arg);
17845         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
17846         return ret_conv;
17847 }
17848
17849 uint64_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint64_t orig) {
17850         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(orig);
17851         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17852         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
17853         return tag_ptr(ret_conv, true);
17854 }
17855
17856 uint64_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint64_tArray b) {
17857         LDKThirtyTwoBytes a_ref;
17858         CHECK(a->arr_len == 32);
17859         memcpy(a_ref.data, a->elems, 32); FREE(a);
17860         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
17861         b_constr.datalen = b->arr_len;
17862         if (b_constr.datalen > 0)
17863                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
17864         else
17865                 b_constr.data = NULL;
17866         uint64_t* b_vals = b->elems;
17867         for (size_t v = 0; v < b_constr.datalen; v++) {
17868                 uint64_t b_conv_21 = b_vals[v];
17869                 void* b_conv_21_ptr = untag_ptr(b_conv_21);
17870                 CHECK_ACCESS(b_conv_21_ptr);
17871                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
17872                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)untag_ptr(b_conv_21));
17873                 b_constr.data[v] = b_conv_21_conv;
17874         }
17875         FREE(b);
17876         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17877         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
17878         return tag_ptr(ret_conv, true);
17879 }
17880
17881 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint64_t _res) {
17882         if (!ptr_is_owned(_res)) return;
17883         void* _res_ptr = untag_ptr(_res);
17884         CHECK_ACCESS(_res_ptr);
17885         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
17886         FREE(untag_ptr(_res));
17887         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
17888 }
17889
17890 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint64_tArray _res) {
17891         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
17892         _res_constr.datalen = _res->arr_len;
17893         if (_res_constr.datalen > 0)
17894                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
17895         else
17896                 _res_constr.data = NULL;
17897         uint64_t* _res_vals = _res->elems;
17898         for (size_t o = 0; o < _res_constr.datalen; o++) {
17899                 uint64_t _res_conv_40 = _res_vals[o];
17900                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
17901                 CHECK_ACCESS(_res_conv_40_ptr);
17902                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
17903                 FREE(untag_ptr(_res_conv_40));
17904                 _res_constr.data[o] = _res_conv_40_conv;
17905         }
17906         FREE(_res);
17907         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
17908 }
17909
17910 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint64_tArray _res) {
17911         LDKCVec_EventZ _res_constr;
17912         _res_constr.datalen = _res->arr_len;
17913         if (_res_constr.datalen > 0)
17914                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
17915         else
17916                 _res_constr.data = NULL;
17917         uint64_t* _res_vals = _res->elems;
17918         for (size_t h = 0; h < _res_constr.datalen; h++) {
17919                 uint64_t _res_conv_7 = _res_vals[h];
17920                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
17921                 CHECK_ACCESS(_res_conv_7_ptr);
17922                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
17923                 FREE(untag_ptr(_res_conv_7));
17924                 _res_constr.data[h] = _res_conv_7_conv;
17925         }
17926         FREE(_res);
17927         CVec_EventZ_free(_res_constr);
17928 }
17929
17930 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
17931         LDKCVec_TransactionZ _res_constr;
17932         _res_constr.datalen = _res->arr_len;
17933         if (_res_constr.datalen > 0)
17934                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
17935         else
17936                 _res_constr.data = NULL;
17937         int8_tArray* _res_vals = (void*) _res->elems;
17938         for (size_t m = 0; m < _res_constr.datalen; m++) {
17939                 int8_tArray _res_conv_12 = _res_vals[m];
17940                 LDKTransaction _res_conv_12_ref;
17941                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
17942                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
17943                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
17944                 _res_conv_12_ref.data_is_owned = true;
17945                 _res_constr.data[m] = _res_conv_12_ref;
17946         }
17947         FREE(_res);
17948         CVec_TransactionZ_free(_res_constr);
17949 }
17950
17951 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
17952         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
17953         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
17954         return tag_ptr(ret_conv, true);
17955 }
17956 int64_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint64_t arg) {
17957         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(arg);
17958         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
17959         return ret_conv;
17960 }
17961
17962 uint64_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint64_t orig) {
17963         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(orig);
17964         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
17965         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
17966         return tag_ptr(ret_conv, true);
17967 }
17968
17969 uint64_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint64_t b) {
17970         void* b_ptr = untag_ptr(b);
17971         CHECK_ACCESS(b_ptr);
17972         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
17973         b_conv = TxOut_clone((LDKTxOut*)untag_ptr(b));
17974         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
17975         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
17976         return tag_ptr(ret_conv, true);
17977 }
17978
17979 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint64_t _res) {
17980         if (!ptr_is_owned(_res)) return;
17981         void* _res_ptr = untag_ptr(_res);
17982         CHECK_ACCESS(_res_ptr);
17983         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
17984         FREE(untag_ptr(_res));
17985         C2Tuple_u32TxOutZ_free(_res_conv);
17986 }
17987
17988 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint64_tArray _res) {
17989         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
17990         _res_constr.datalen = _res->arr_len;
17991         if (_res_constr.datalen > 0)
17992                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
17993         else
17994                 _res_constr.data = NULL;
17995         uint64_t* _res_vals = _res->elems;
17996         for (size_t u = 0; u < _res_constr.datalen; u++) {
17997                 uint64_t _res_conv_20 = _res_vals[u];
17998                 void* _res_conv_20_ptr = untag_ptr(_res_conv_20);
17999                 CHECK_ACCESS(_res_conv_20_ptr);
18000                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
18001                 FREE(untag_ptr(_res_conv_20));
18002                 _res_constr.data[u] = _res_conv_20_conv;
18003         }
18004         FREE(_res);
18005         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
18006 }
18007
18008 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
18009         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18010         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
18011         return tag_ptr(ret_conv, true);
18012 }
18013 int64_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint64_t arg) {
18014         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(arg);
18015         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
18016         return ret_conv;
18017 }
18018
18019 uint64_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint64_t orig) {
18020         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(orig);
18021         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18022         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
18023         return tag_ptr(ret_conv, true);
18024 }
18025
18026 uint64_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint64_tArray b) {
18027         LDKThirtyTwoBytes a_ref;
18028         CHECK(a->arr_len == 32);
18029         memcpy(a_ref.data, a->elems, 32); FREE(a);
18030         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
18031         b_constr.datalen = b->arr_len;
18032         if (b_constr.datalen > 0)
18033                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
18034         else
18035                 b_constr.data = NULL;
18036         uint64_t* b_vals = b->elems;
18037         for (size_t u = 0; u < b_constr.datalen; u++) {
18038                 uint64_t b_conv_20 = b_vals[u];
18039                 void* b_conv_20_ptr = untag_ptr(b_conv_20);
18040                 CHECK_ACCESS(b_conv_20_ptr);
18041                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
18042                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)untag_ptr(b_conv_20));
18043                 b_constr.data[u] = b_conv_20_conv;
18044         }
18045         FREE(b);
18046         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18047         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
18048         return tag_ptr(ret_conv, true);
18049 }
18050
18051 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint64_t _res) {
18052         if (!ptr_is_owned(_res)) return;
18053         void* _res_ptr = untag_ptr(_res);
18054         CHECK_ACCESS(_res_ptr);
18055         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
18056         FREE(untag_ptr(_res));
18057         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
18058 }
18059
18060 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint64_tArray _res) {
18061         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
18062         _res_constr.datalen = _res->arr_len;
18063         if (_res_constr.datalen > 0)
18064                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
18065         else
18066                 _res_constr.data = NULL;
18067         uint64_t* _res_vals = _res->elems;
18068         for (size_t n = 0; n < _res_constr.datalen; n++) {
18069                 uint64_t _res_conv_39 = _res_vals[n];
18070                 void* _res_conv_39_ptr = untag_ptr(_res_conv_39);
18071                 CHECK_ACCESS(_res_conv_39_ptr);
18072                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
18073                 FREE(untag_ptr(_res_conv_39));
18074                 _res_constr.data[n] = _res_conv_39_conv;
18075         }
18076         FREE(_res);
18077         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
18078 }
18079
18080 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint64_tArray _res) {
18081         LDKCVec_BalanceZ _res_constr;
18082         _res_constr.datalen = _res->arr_len;
18083         if (_res_constr.datalen > 0)
18084                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
18085         else
18086                 _res_constr.data = NULL;
18087         uint64_t* _res_vals = _res->elems;
18088         for (size_t j = 0; j < _res_constr.datalen; j++) {
18089                 uint64_t _res_conv_9 = _res_vals[j];
18090                 void* _res_conv_9_ptr = untag_ptr(_res_conv_9);
18091                 CHECK_ACCESS(_res_conv_9_ptr);
18092                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
18093                 FREE(untag_ptr(_res_conv_9));
18094                 _res_constr.data[j] = _res_conv_9_conv;
18095         }
18096         FREE(_res);
18097         CVec_BalanceZ_free(_res_constr);
18098 }
18099
18100 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
18101         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18102         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
18103         return tag_ptr(ret_conv, true);
18104 }
18105 int64_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint64_t arg) {
18106         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(arg);
18107         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
18108         return ret_conv;
18109 }
18110
18111 uint64_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint64_t orig) {
18112         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(orig);
18113         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18114         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
18115         return tag_ptr(ret_conv, true);
18116 }
18117
18118 uint64_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint64_t b) {
18119         LDKThirtyTwoBytes a_ref;
18120         CHECK(a->arr_len == 32);
18121         memcpy(a_ref.data, a->elems, 32); FREE(a);
18122         LDKChannelMonitor b_conv;
18123         b_conv.inner = untag_ptr(b);
18124         b_conv.is_owned = ptr_is_owned(b);
18125         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18126         b_conv = ChannelMonitor_clone(&b_conv);
18127         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18128         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
18129         return tag_ptr(ret_conv, true);
18130 }
18131
18132 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint64_t _res) {
18133         if (!ptr_is_owned(_res)) return;
18134         void* _res_ptr = untag_ptr(_res);
18135         CHECK_ACCESS(_res_ptr);
18136         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
18137         FREE(untag_ptr(_res));
18138         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
18139 }
18140
18141 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint64_t o) {
18142         void* o_ptr = untag_ptr(o);
18143         CHECK_ACCESS(o_ptr);
18144         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
18145         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o));
18146         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18147         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
18148         return tag_ptr(ret_conv, true);
18149 }
18150
18151 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint64_t e) {
18152         LDKDecodeError e_conv;
18153         e_conv.inner = untag_ptr(e);
18154         e_conv.is_owned = ptr_is_owned(e);
18155         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18156         e_conv = DecodeError_clone(&e_conv);
18157         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18158         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
18159         return tag_ptr(ret_conv, true);
18160 }
18161
18162 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint64_t o) {
18163         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(o);
18164         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
18165         return ret_conv;
18166 }
18167
18168 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint64_t _res) {
18169         if (!ptr_is_owned(_res)) return;
18170         void* _res_ptr = untag_ptr(_res);
18171         CHECK_ACCESS(_res_ptr);
18172         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
18173         FREE(untag_ptr(_res));
18174         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
18175 }
18176
18177 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
18178         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18179         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
18180         return tag_ptr(ret_conv, true);
18181 }
18182 int64_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint64_t arg) {
18183         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(arg);
18184         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
18185         return ret_conv;
18186 }
18187
18188 uint64_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint64_t orig) {
18189         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(orig);
18190         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18191         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
18192         return tag_ptr(ret_conv, true);
18193 }
18194
18195 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
18196         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18197         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
18198         return tag_ptr(ret_conv, true);
18199 }
18200 int64_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint64_t arg) {
18201         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(arg);
18202         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
18203         return ret_conv;
18204 }
18205
18206 uint64_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint64_t orig) {
18207         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(orig);
18208         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18209         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
18210         return tag_ptr(ret_conv, true);
18211 }
18212
18213 uint64_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint64_t b) {
18214         LDKPublicKey a_ref;
18215         CHECK(a->arr_len == 33);
18216         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
18217         void* b_ptr = untag_ptr(b);
18218         CHECK_ACCESS(b_ptr);
18219         LDKType b_conv = *(LDKType*)(b_ptr);
18220         if (b_conv.free == LDKType_JCalls_free) {
18221                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18222                 LDKType_JCalls_cloned(&b_conv);
18223         }
18224         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18225         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
18226         return tag_ptr(ret_conv, true);
18227 }
18228
18229 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint64_t _res) {
18230         if (!ptr_is_owned(_res)) return;
18231         void* _res_ptr = untag_ptr(_res);
18232         CHECK_ACCESS(_res_ptr);
18233         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
18234         FREE(untag_ptr(_res));
18235         C2Tuple_PublicKeyTypeZ_free(_res_conv);
18236 }
18237
18238 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint64_tArray _res) {
18239         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
18240         _res_constr.datalen = _res->arr_len;
18241         if (_res_constr.datalen > 0)
18242                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
18243         else
18244                 _res_constr.data = NULL;
18245         uint64_t* _res_vals = _res->elems;
18246         for (size_t z = 0; z < _res_constr.datalen; z++) {
18247                 uint64_t _res_conv_25 = _res_vals[z];
18248                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
18249                 CHECK_ACCESS(_res_conv_25_ptr);
18250                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
18251                 FREE(untag_ptr(_res_conv_25));
18252                 _res_constr.data[z] = _res_conv_25_conv;
18253         }
18254         FREE(_res);
18255         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
18256 }
18257
18258 uint64_t  __attribute__((export_name("TS_COption_NetAddressZ_some"))) TS_COption_NetAddressZ_some(uint64_t o) {
18259         void* o_ptr = untag_ptr(o);
18260         CHECK_ACCESS(o_ptr);
18261         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
18262         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
18263         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18264         *ret_copy = COption_NetAddressZ_some(o_conv);
18265         uint64_t ret_ref = tag_ptr(ret_copy, true);
18266         return ret_ref;
18267 }
18268
18269 uint64_t  __attribute__((export_name("TS_COption_NetAddressZ_none"))) TS_COption_NetAddressZ_none() {
18270         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18271         *ret_copy = COption_NetAddressZ_none();
18272         uint64_t ret_ref = tag_ptr(ret_copy, true);
18273         return ret_ref;
18274 }
18275
18276 void  __attribute__((export_name("TS_COption_NetAddressZ_free"))) TS_COption_NetAddressZ_free(uint64_t _res) {
18277         if (!ptr_is_owned(_res)) return;
18278         void* _res_ptr = untag_ptr(_res);
18279         CHECK_ACCESS(_res_ptr);
18280         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
18281         FREE(untag_ptr(_res));
18282         COption_NetAddressZ_free(_res_conv);
18283 }
18284
18285 static inline uint64_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
18286         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18287         *ret_copy = COption_NetAddressZ_clone(arg);
18288         uint64_t ret_ref = tag_ptr(ret_copy, true);
18289         return ret_ref;
18290 }
18291 int64_t  __attribute__((export_name("TS_COption_NetAddressZ_clone_ptr"))) TS_COption_NetAddressZ_clone_ptr(uint64_t arg) {
18292         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)untag_ptr(arg);
18293         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
18294         return ret_conv;
18295 }
18296
18297 uint64_t  __attribute__((export_name("TS_COption_NetAddressZ_clone"))) TS_COption_NetAddressZ_clone(uint64_t orig) {
18298         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)untag_ptr(orig);
18299         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18300         *ret_copy = COption_NetAddressZ_clone(orig_conv);
18301         uint64_t ret_ref = tag_ptr(ret_copy, true);
18302         return ret_ref;
18303 }
18304
18305 uint64_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
18306         LDKCVec_u8Z o_ref;
18307         o_ref.datalen = o->arr_len;
18308         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
18309         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
18310         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18311         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
18312         return tag_ptr(ret_conv, true);
18313 }
18314
18315 uint64_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint64_t e) {
18316         LDKPeerHandleError e_conv;
18317         e_conv.inner = untag_ptr(e);
18318         e_conv.is_owned = ptr_is_owned(e);
18319         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18320         e_conv = PeerHandleError_clone(&e_conv);
18321         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18322         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
18323         return tag_ptr(ret_conv, true);
18324 }
18325
18326 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint64_t o) {
18327         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(o);
18328         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
18329         return ret_conv;
18330 }
18331
18332 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint64_t _res) {
18333         if (!ptr_is_owned(_res)) return;
18334         void* _res_ptr = untag_ptr(_res);
18335         CHECK_ACCESS(_res_ptr);
18336         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
18337         FREE(untag_ptr(_res));
18338         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
18339 }
18340
18341 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
18342         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18343         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
18344         return tag_ptr(ret_conv, true);
18345 }
18346 int64_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint64_t arg) {
18347         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(arg);
18348         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
18349         return ret_conv;
18350 }
18351
18352 uint64_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint64_t orig) {
18353         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(orig);
18354         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18355         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
18356         return tag_ptr(ret_conv, true);
18357 }
18358
18359 uint64_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
18360         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18361         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
18362         return tag_ptr(ret_conv, true);
18363 }
18364
18365 uint64_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint64_t e) {
18366         LDKPeerHandleError e_conv;
18367         e_conv.inner = untag_ptr(e);
18368         e_conv.is_owned = ptr_is_owned(e);
18369         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18370         e_conv = PeerHandleError_clone(&e_conv);
18371         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18372         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
18373         return tag_ptr(ret_conv, true);
18374 }
18375
18376 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint64_t o) {
18377         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(o);
18378         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
18379         return ret_conv;
18380 }
18381
18382 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint64_t _res) {
18383         if (!ptr_is_owned(_res)) return;
18384         void* _res_ptr = untag_ptr(_res);
18385         CHECK_ACCESS(_res_ptr);
18386         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
18387         FREE(untag_ptr(_res));
18388         CResult_NonePeerHandleErrorZ_free(_res_conv);
18389 }
18390
18391 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
18392         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18393         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
18394         return tag_ptr(ret_conv, true);
18395 }
18396 int64_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint64_t arg) {
18397         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(arg);
18398         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
18399         return ret_conv;
18400 }
18401
18402 uint64_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint64_t orig) {
18403         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(orig);
18404         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18405         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
18406         return tag_ptr(ret_conv, true);
18407 }
18408
18409 uint64_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
18410         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18411         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
18412         return tag_ptr(ret_conv, true);
18413 }
18414
18415 uint64_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint64_t e) {
18416         LDKPeerHandleError e_conv;
18417         e_conv.inner = untag_ptr(e);
18418         e_conv.is_owned = ptr_is_owned(e);
18419         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18420         e_conv = PeerHandleError_clone(&e_conv);
18421         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18422         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
18423         return tag_ptr(ret_conv, true);
18424 }
18425
18426 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint64_t o) {
18427         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(o);
18428         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
18429         return ret_conv;
18430 }
18431
18432 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint64_t _res) {
18433         if (!ptr_is_owned(_res)) return;
18434         void* _res_ptr = untag_ptr(_res);
18435         CHECK_ACCESS(_res_ptr);
18436         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
18437         FREE(untag_ptr(_res));
18438         CResult_boolPeerHandleErrorZ_free(_res_conv);
18439 }
18440
18441 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
18442         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18443         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
18444         return tag_ptr(ret_conv, true);
18445 }
18446 int64_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint64_t arg) {
18447         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(arg);
18448         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
18449         return ret_conv;
18450 }
18451
18452 uint64_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint64_t orig) {
18453         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(orig);
18454         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18455         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
18456         return tag_ptr(ret_conv, true);
18457 }
18458
18459 uint64_t  __attribute__((export_name("TS_CResult_NoneSendErrorZ_ok"))) TS_CResult_NoneSendErrorZ_ok() {
18460         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
18461         *ret_conv = CResult_NoneSendErrorZ_ok();
18462         return tag_ptr(ret_conv, true);
18463 }
18464
18465 uint64_t  __attribute__((export_name("TS_CResult_NoneSendErrorZ_err"))) TS_CResult_NoneSendErrorZ_err(uint64_t e) {
18466         void* e_ptr = untag_ptr(e);
18467         CHECK_ACCESS(e_ptr);
18468         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
18469         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
18470         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
18471         *ret_conv = CResult_NoneSendErrorZ_err(e_conv);
18472         return tag_ptr(ret_conv, true);
18473 }
18474
18475 jboolean  __attribute__((export_name("TS_CResult_NoneSendErrorZ_is_ok"))) TS_CResult_NoneSendErrorZ_is_ok(uint64_t o) {
18476         LDKCResult_NoneSendErrorZ* o_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(o);
18477         jboolean ret_conv = CResult_NoneSendErrorZ_is_ok(o_conv);
18478         return ret_conv;
18479 }
18480
18481 void  __attribute__((export_name("TS_CResult_NoneSendErrorZ_free"))) TS_CResult_NoneSendErrorZ_free(uint64_t _res) {
18482         if (!ptr_is_owned(_res)) return;
18483         void* _res_ptr = untag_ptr(_res);
18484         CHECK_ACCESS(_res_ptr);
18485         LDKCResult_NoneSendErrorZ _res_conv = *(LDKCResult_NoneSendErrorZ*)(_res_ptr);
18486         FREE(untag_ptr(_res));
18487         CResult_NoneSendErrorZ_free(_res_conv);
18488 }
18489
18490 uint64_t  __attribute__((export_name("TS_CResult_NoneErrorZ_ok"))) TS_CResult_NoneErrorZ_ok() {
18491         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18492         *ret_conv = CResult_NoneErrorZ_ok();
18493         return tag_ptr(ret_conv, true);
18494 }
18495
18496 uint64_t  __attribute__((export_name("TS_CResult_NoneErrorZ_err"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
18497         LDKIOError e_conv = LDKIOError_from_js(e);
18498         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18499         *ret_conv = CResult_NoneErrorZ_err(e_conv);
18500         return tag_ptr(ret_conv, true);
18501 }
18502
18503 jboolean  __attribute__((export_name("TS_CResult_NoneErrorZ_is_ok"))) TS_CResult_NoneErrorZ_is_ok(uint64_t o) {
18504         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)untag_ptr(o);
18505         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
18506         return ret_conv;
18507 }
18508
18509 void  __attribute__((export_name("TS_CResult_NoneErrorZ_free"))) TS_CResult_NoneErrorZ_free(uint64_t _res) {
18510         if (!ptr_is_owned(_res)) return;
18511         void* _res_ptr = untag_ptr(_res);
18512         CHECK_ACCESS(_res_ptr);
18513         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
18514         FREE(untag_ptr(_res));
18515         CResult_NoneErrorZ_free(_res_conv);
18516 }
18517
18518 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
18519         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18520         *ret_conv = CResult_NoneErrorZ_clone(arg);
18521         return tag_ptr(ret_conv, true);
18522 }
18523 int64_t  __attribute__((export_name("TS_CResult_NoneErrorZ_clone_ptr"))) TS_CResult_NoneErrorZ_clone_ptr(uint64_t arg) {
18524         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)untag_ptr(arg);
18525         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
18526         return ret_conv;
18527 }
18528
18529 uint64_t  __attribute__((export_name("TS_CResult_NoneErrorZ_clone"))) TS_CResult_NoneErrorZ_clone(uint64_t orig) {
18530         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)untag_ptr(orig);
18531         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18532         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
18533         return tag_ptr(ret_conv, true);
18534 }
18535
18536 uint64_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint64_t o) {
18537         void* o_ptr = untag_ptr(o);
18538         CHECK_ACCESS(o_ptr);
18539         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
18540         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
18541         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18542         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
18543         return tag_ptr(ret_conv, true);
18544 }
18545
18546 uint64_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint64_t e) {
18547         LDKDecodeError e_conv;
18548         e_conv.inner = untag_ptr(e);
18549         e_conv.is_owned = ptr_is_owned(e);
18550         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18551         e_conv = DecodeError_clone(&e_conv);
18552         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18553         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
18554         return tag_ptr(ret_conv, true);
18555 }
18556
18557 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint64_t o) {
18558         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(o);
18559         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
18560         return ret_conv;
18561 }
18562
18563 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint64_t _res) {
18564         if (!ptr_is_owned(_res)) return;
18565         void* _res_ptr = untag_ptr(_res);
18566         CHECK_ACCESS(_res_ptr);
18567         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
18568         FREE(untag_ptr(_res));
18569         CResult_NetAddressDecodeErrorZ_free(_res_conv);
18570 }
18571
18572 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
18573         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18574         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
18575         return tag_ptr(ret_conv, true);
18576 }
18577 int64_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint64_t arg) {
18578         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(arg);
18579         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
18580         return ret_conv;
18581 }
18582
18583 uint64_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint64_t orig) {
18584         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(orig);
18585         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18586         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
18587         return tag_ptr(ret_conv, true);
18588 }
18589
18590 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint64_tArray _res) {
18591         LDKCVec_UpdateAddHTLCZ _res_constr;
18592         _res_constr.datalen = _res->arr_len;
18593         if (_res_constr.datalen > 0)
18594                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
18595         else
18596                 _res_constr.data = NULL;
18597         uint64_t* _res_vals = _res->elems;
18598         for (size_t p = 0; p < _res_constr.datalen; p++) {
18599                 uint64_t _res_conv_15 = _res_vals[p];
18600                 LDKUpdateAddHTLC _res_conv_15_conv;
18601                 _res_conv_15_conv.inner = untag_ptr(_res_conv_15);
18602                 _res_conv_15_conv.is_owned = ptr_is_owned(_res_conv_15);
18603                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
18604                 _res_constr.data[p] = _res_conv_15_conv;
18605         }
18606         FREE(_res);
18607         CVec_UpdateAddHTLCZ_free(_res_constr);
18608 }
18609
18610 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint64_tArray _res) {
18611         LDKCVec_UpdateFulfillHTLCZ _res_constr;
18612         _res_constr.datalen = _res->arr_len;
18613         if (_res_constr.datalen > 0)
18614                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
18615         else
18616                 _res_constr.data = NULL;
18617         uint64_t* _res_vals = _res->elems;
18618         for (size_t t = 0; t < _res_constr.datalen; t++) {
18619                 uint64_t _res_conv_19 = _res_vals[t];
18620                 LDKUpdateFulfillHTLC _res_conv_19_conv;
18621                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
18622                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
18623                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
18624                 _res_constr.data[t] = _res_conv_19_conv;
18625         }
18626         FREE(_res);
18627         CVec_UpdateFulfillHTLCZ_free(_res_constr);
18628 }
18629
18630 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint64_tArray _res) {
18631         LDKCVec_UpdateFailHTLCZ _res_constr;
18632         _res_constr.datalen = _res->arr_len;
18633         if (_res_constr.datalen > 0)
18634                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
18635         else
18636                 _res_constr.data = NULL;
18637         uint64_t* _res_vals = _res->elems;
18638         for (size_t q = 0; q < _res_constr.datalen; q++) {
18639                 uint64_t _res_conv_16 = _res_vals[q];
18640                 LDKUpdateFailHTLC _res_conv_16_conv;
18641                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
18642                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
18643                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
18644                 _res_constr.data[q] = _res_conv_16_conv;
18645         }
18646         FREE(_res);
18647         CVec_UpdateFailHTLCZ_free(_res_constr);
18648 }
18649
18650 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint64_tArray _res) {
18651         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
18652         _res_constr.datalen = _res->arr_len;
18653         if (_res_constr.datalen > 0)
18654                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
18655         else
18656                 _res_constr.data = NULL;
18657         uint64_t* _res_vals = _res->elems;
18658         for (size_t z = 0; z < _res_constr.datalen; z++) {
18659                 uint64_t _res_conv_25 = _res_vals[z];
18660                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
18661                 _res_conv_25_conv.inner = untag_ptr(_res_conv_25);
18662                 _res_conv_25_conv.is_owned = ptr_is_owned(_res_conv_25);
18663                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
18664                 _res_constr.data[z] = _res_conv_25_conv;
18665         }
18666         FREE(_res);
18667         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
18668 }
18669
18670 uint64_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint64_t o) {
18671         LDKAcceptChannel o_conv;
18672         o_conv.inner = untag_ptr(o);
18673         o_conv.is_owned = ptr_is_owned(o);
18674         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18675         o_conv = AcceptChannel_clone(&o_conv);
18676         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18677         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
18678         return tag_ptr(ret_conv, true);
18679 }
18680
18681 uint64_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint64_t e) {
18682         LDKDecodeError e_conv;
18683         e_conv.inner = untag_ptr(e);
18684         e_conv.is_owned = ptr_is_owned(e);
18685         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18686         e_conv = DecodeError_clone(&e_conv);
18687         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18688         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
18689         return tag_ptr(ret_conv, true);
18690 }
18691
18692 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint64_t o) {
18693         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(o);
18694         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
18695         return ret_conv;
18696 }
18697
18698 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint64_t _res) {
18699         if (!ptr_is_owned(_res)) return;
18700         void* _res_ptr = untag_ptr(_res);
18701         CHECK_ACCESS(_res_ptr);
18702         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
18703         FREE(untag_ptr(_res));
18704         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
18705 }
18706
18707 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
18708         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18709         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
18710         return tag_ptr(ret_conv, true);
18711 }
18712 int64_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint64_t arg) {
18713         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(arg);
18714         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
18715         return ret_conv;
18716 }
18717
18718 uint64_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint64_t orig) {
18719         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(orig);
18720         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18721         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
18722         return tag_ptr(ret_conv, true);
18723 }
18724
18725 uint64_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint64_t o) {
18726         LDKAnnouncementSignatures o_conv;
18727         o_conv.inner = untag_ptr(o);
18728         o_conv.is_owned = ptr_is_owned(o);
18729         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18730         o_conv = AnnouncementSignatures_clone(&o_conv);
18731         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18732         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
18733         return tag_ptr(ret_conv, true);
18734 }
18735
18736 uint64_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint64_t e) {
18737         LDKDecodeError e_conv;
18738         e_conv.inner = untag_ptr(e);
18739         e_conv.is_owned = ptr_is_owned(e);
18740         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18741         e_conv = DecodeError_clone(&e_conv);
18742         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18743         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
18744         return tag_ptr(ret_conv, true);
18745 }
18746
18747 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint64_t o) {
18748         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(o);
18749         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
18750         return ret_conv;
18751 }
18752
18753 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint64_t _res) {
18754         if (!ptr_is_owned(_res)) return;
18755         void* _res_ptr = untag_ptr(_res);
18756         CHECK_ACCESS(_res_ptr);
18757         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
18758         FREE(untag_ptr(_res));
18759         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
18760 }
18761
18762 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
18763         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18764         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
18765         return tag_ptr(ret_conv, true);
18766 }
18767 int64_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint64_t arg) {
18768         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(arg);
18769         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
18770         return ret_conv;
18771 }
18772
18773 uint64_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint64_t orig) {
18774         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(orig);
18775         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18776         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
18777         return tag_ptr(ret_conv, true);
18778 }
18779
18780 uint64_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint64_t o) {
18781         LDKChannelReestablish o_conv;
18782         o_conv.inner = untag_ptr(o);
18783         o_conv.is_owned = ptr_is_owned(o);
18784         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18785         o_conv = ChannelReestablish_clone(&o_conv);
18786         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18787         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
18788         return tag_ptr(ret_conv, true);
18789 }
18790
18791 uint64_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint64_t e) {
18792         LDKDecodeError e_conv;
18793         e_conv.inner = untag_ptr(e);
18794         e_conv.is_owned = ptr_is_owned(e);
18795         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18796         e_conv = DecodeError_clone(&e_conv);
18797         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18798         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
18799         return tag_ptr(ret_conv, true);
18800 }
18801
18802 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint64_t o) {
18803         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(o);
18804         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
18805         return ret_conv;
18806 }
18807
18808 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint64_t _res) {
18809         if (!ptr_is_owned(_res)) return;
18810         void* _res_ptr = untag_ptr(_res);
18811         CHECK_ACCESS(_res_ptr);
18812         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
18813         FREE(untag_ptr(_res));
18814         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
18815 }
18816
18817 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
18818         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18819         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
18820         return tag_ptr(ret_conv, true);
18821 }
18822 int64_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint64_t arg) {
18823         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(arg);
18824         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
18825         return ret_conv;
18826 }
18827
18828 uint64_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint64_t orig) {
18829         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(orig);
18830         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18831         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
18832         return tag_ptr(ret_conv, true);
18833 }
18834
18835 uint64_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint64_t o) {
18836         LDKClosingSigned o_conv;
18837         o_conv.inner = untag_ptr(o);
18838         o_conv.is_owned = ptr_is_owned(o);
18839         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18840         o_conv = ClosingSigned_clone(&o_conv);
18841         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18842         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
18843         return tag_ptr(ret_conv, true);
18844 }
18845
18846 uint64_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint64_t e) {
18847         LDKDecodeError e_conv;
18848         e_conv.inner = untag_ptr(e);
18849         e_conv.is_owned = ptr_is_owned(e);
18850         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18851         e_conv = DecodeError_clone(&e_conv);
18852         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18853         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
18854         return tag_ptr(ret_conv, true);
18855 }
18856
18857 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint64_t o) {
18858         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(o);
18859         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
18860         return ret_conv;
18861 }
18862
18863 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint64_t _res) {
18864         if (!ptr_is_owned(_res)) return;
18865         void* _res_ptr = untag_ptr(_res);
18866         CHECK_ACCESS(_res_ptr);
18867         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
18868         FREE(untag_ptr(_res));
18869         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
18870 }
18871
18872 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
18873         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18874         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
18875         return tag_ptr(ret_conv, true);
18876 }
18877 int64_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint64_t arg) {
18878         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(arg);
18879         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
18880         return ret_conv;
18881 }
18882
18883 uint64_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint64_t orig) {
18884         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(orig);
18885         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18886         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
18887         return tag_ptr(ret_conv, true);
18888 }
18889
18890 uint64_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint64_t o) {
18891         LDKClosingSignedFeeRange o_conv;
18892         o_conv.inner = untag_ptr(o);
18893         o_conv.is_owned = ptr_is_owned(o);
18894         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18895         o_conv = ClosingSignedFeeRange_clone(&o_conv);
18896         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18897         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
18898         return tag_ptr(ret_conv, true);
18899 }
18900
18901 uint64_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint64_t e) {
18902         LDKDecodeError e_conv;
18903         e_conv.inner = untag_ptr(e);
18904         e_conv.is_owned = ptr_is_owned(e);
18905         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18906         e_conv = DecodeError_clone(&e_conv);
18907         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18908         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
18909         return tag_ptr(ret_conv, true);
18910 }
18911
18912 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint64_t o) {
18913         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(o);
18914         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
18915         return ret_conv;
18916 }
18917
18918 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint64_t _res) {
18919         if (!ptr_is_owned(_res)) return;
18920         void* _res_ptr = untag_ptr(_res);
18921         CHECK_ACCESS(_res_ptr);
18922         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
18923         FREE(untag_ptr(_res));
18924         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
18925 }
18926
18927 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
18928         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18929         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
18930         return tag_ptr(ret_conv, true);
18931 }
18932 int64_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint64_t arg) {
18933         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(arg);
18934         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
18935         return ret_conv;
18936 }
18937
18938 uint64_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint64_t orig) {
18939         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(orig);
18940         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18941         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
18942         return tag_ptr(ret_conv, true);
18943 }
18944
18945 uint64_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint64_t o) {
18946         LDKCommitmentSigned o_conv;
18947         o_conv.inner = untag_ptr(o);
18948         o_conv.is_owned = ptr_is_owned(o);
18949         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18950         o_conv = CommitmentSigned_clone(&o_conv);
18951         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18952         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
18953         return tag_ptr(ret_conv, true);
18954 }
18955
18956 uint64_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint64_t e) {
18957         LDKDecodeError e_conv;
18958         e_conv.inner = untag_ptr(e);
18959         e_conv.is_owned = ptr_is_owned(e);
18960         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18961         e_conv = DecodeError_clone(&e_conv);
18962         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18963         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
18964         return tag_ptr(ret_conv, true);
18965 }
18966
18967 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint64_t o) {
18968         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(o);
18969         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
18970         return ret_conv;
18971 }
18972
18973 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint64_t _res) {
18974         if (!ptr_is_owned(_res)) return;
18975         void* _res_ptr = untag_ptr(_res);
18976         CHECK_ACCESS(_res_ptr);
18977         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
18978         FREE(untag_ptr(_res));
18979         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
18980 }
18981
18982 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
18983         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18984         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
18985         return tag_ptr(ret_conv, true);
18986 }
18987 int64_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint64_t arg) {
18988         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(arg);
18989         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
18990         return ret_conv;
18991 }
18992
18993 uint64_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint64_t orig) {
18994         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(orig);
18995         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18996         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
18997         return tag_ptr(ret_conv, true);
18998 }
18999
19000 uint64_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint64_t o) {
19001         LDKFundingCreated o_conv;
19002         o_conv.inner = untag_ptr(o);
19003         o_conv.is_owned = ptr_is_owned(o);
19004         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19005         o_conv = FundingCreated_clone(&o_conv);
19006         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19007         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
19008         return tag_ptr(ret_conv, true);
19009 }
19010
19011 uint64_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint64_t e) {
19012         LDKDecodeError e_conv;
19013         e_conv.inner = untag_ptr(e);
19014         e_conv.is_owned = ptr_is_owned(e);
19015         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19016         e_conv = DecodeError_clone(&e_conv);
19017         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19018         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
19019         return tag_ptr(ret_conv, true);
19020 }
19021
19022 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint64_t o) {
19023         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(o);
19024         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
19025         return ret_conv;
19026 }
19027
19028 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint64_t _res) {
19029         if (!ptr_is_owned(_res)) return;
19030         void* _res_ptr = untag_ptr(_res);
19031         CHECK_ACCESS(_res_ptr);
19032         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
19033         FREE(untag_ptr(_res));
19034         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
19035 }
19036
19037 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
19038         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19039         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
19040         return tag_ptr(ret_conv, true);
19041 }
19042 int64_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint64_t arg) {
19043         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(arg);
19044         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
19045         return ret_conv;
19046 }
19047
19048 uint64_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint64_t orig) {
19049         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(orig);
19050         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19051         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
19052         return tag_ptr(ret_conv, true);
19053 }
19054
19055 uint64_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint64_t o) {
19056         LDKFundingSigned o_conv;
19057         o_conv.inner = untag_ptr(o);
19058         o_conv.is_owned = ptr_is_owned(o);
19059         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19060         o_conv = FundingSigned_clone(&o_conv);
19061         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19062         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
19063         return tag_ptr(ret_conv, true);
19064 }
19065
19066 uint64_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint64_t e) {
19067         LDKDecodeError e_conv;
19068         e_conv.inner = untag_ptr(e);
19069         e_conv.is_owned = ptr_is_owned(e);
19070         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19071         e_conv = DecodeError_clone(&e_conv);
19072         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19073         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
19074         return tag_ptr(ret_conv, true);
19075 }
19076
19077 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint64_t o) {
19078         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(o);
19079         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
19080         return ret_conv;
19081 }
19082
19083 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint64_t _res) {
19084         if (!ptr_is_owned(_res)) return;
19085         void* _res_ptr = untag_ptr(_res);
19086         CHECK_ACCESS(_res_ptr);
19087         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
19088         FREE(untag_ptr(_res));
19089         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
19090 }
19091
19092 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
19093         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19094         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
19095         return tag_ptr(ret_conv, true);
19096 }
19097 int64_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint64_t arg) {
19098         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(arg);
19099         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
19100         return ret_conv;
19101 }
19102
19103 uint64_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint64_t orig) {
19104         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(orig);
19105         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19106         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
19107         return tag_ptr(ret_conv, true);
19108 }
19109
19110 uint64_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_ok(uint64_t o) {
19111         LDKChannelReady o_conv;
19112         o_conv.inner = untag_ptr(o);
19113         o_conv.is_owned = ptr_is_owned(o);
19114         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19115         o_conv = ChannelReady_clone(&o_conv);
19116         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19117         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
19118         return tag_ptr(ret_conv, true);
19119 }
19120
19121 uint64_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_err"))) TS_CResult_ChannelReadyDecodeErrorZ_err(uint64_t e) {
19122         LDKDecodeError e_conv;
19123         e_conv.inner = untag_ptr(e);
19124         e_conv.is_owned = ptr_is_owned(e);
19125         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19126         e_conv = DecodeError_clone(&e_conv);
19127         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19128         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
19129         return tag_ptr(ret_conv, true);
19130 }
19131
19132 jboolean  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_is_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_is_ok(uint64_t o) {
19133         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(o);
19134         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
19135         return ret_conv;
19136 }
19137
19138 void  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_free"))) TS_CResult_ChannelReadyDecodeErrorZ_free(uint64_t _res) {
19139         if (!ptr_is_owned(_res)) return;
19140         void* _res_ptr = untag_ptr(_res);
19141         CHECK_ACCESS(_res_ptr);
19142         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
19143         FREE(untag_ptr(_res));
19144         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
19145 }
19146
19147 static inline uint64_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
19148         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19149         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
19150         return tag_ptr(ret_conv, true);
19151 }
19152 int64_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReadyDecodeErrorZ_clone_ptr(uint64_t arg) {
19153         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(arg);
19154         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
19155         return ret_conv;
19156 }
19157
19158 uint64_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_clone"))) TS_CResult_ChannelReadyDecodeErrorZ_clone(uint64_t orig) {
19159         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(orig);
19160         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19161         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
19162         return tag_ptr(ret_conv, true);
19163 }
19164
19165 uint64_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint64_t o) {
19166         LDKInit o_conv;
19167         o_conv.inner = untag_ptr(o);
19168         o_conv.is_owned = ptr_is_owned(o);
19169         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19170         o_conv = Init_clone(&o_conv);
19171         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19172         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
19173         return tag_ptr(ret_conv, true);
19174 }
19175
19176 uint64_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint64_t e) {
19177         LDKDecodeError e_conv;
19178         e_conv.inner = untag_ptr(e);
19179         e_conv.is_owned = ptr_is_owned(e);
19180         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19181         e_conv = DecodeError_clone(&e_conv);
19182         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19183         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
19184         return tag_ptr(ret_conv, true);
19185 }
19186
19187 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint64_t o) {
19188         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(o);
19189         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
19190         return ret_conv;
19191 }
19192
19193 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint64_t _res) {
19194         if (!ptr_is_owned(_res)) return;
19195         void* _res_ptr = untag_ptr(_res);
19196         CHECK_ACCESS(_res_ptr);
19197         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
19198         FREE(untag_ptr(_res));
19199         CResult_InitDecodeErrorZ_free(_res_conv);
19200 }
19201
19202 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
19203         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19204         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
19205         return tag_ptr(ret_conv, true);
19206 }
19207 int64_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint64_t arg) {
19208         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(arg);
19209         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
19210         return ret_conv;
19211 }
19212
19213 uint64_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint64_t orig) {
19214         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(orig);
19215         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19216         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
19217         return tag_ptr(ret_conv, true);
19218 }
19219
19220 uint64_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint64_t o) {
19221         LDKOpenChannel o_conv;
19222         o_conv.inner = untag_ptr(o);
19223         o_conv.is_owned = ptr_is_owned(o);
19224         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19225         o_conv = OpenChannel_clone(&o_conv);
19226         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19227         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
19228         return tag_ptr(ret_conv, true);
19229 }
19230
19231 uint64_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint64_t e) {
19232         LDKDecodeError e_conv;
19233         e_conv.inner = untag_ptr(e);
19234         e_conv.is_owned = ptr_is_owned(e);
19235         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19236         e_conv = DecodeError_clone(&e_conv);
19237         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19238         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
19239         return tag_ptr(ret_conv, true);
19240 }
19241
19242 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint64_t o) {
19243         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(o);
19244         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
19245         return ret_conv;
19246 }
19247
19248 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint64_t _res) {
19249         if (!ptr_is_owned(_res)) return;
19250         void* _res_ptr = untag_ptr(_res);
19251         CHECK_ACCESS(_res_ptr);
19252         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
19253         FREE(untag_ptr(_res));
19254         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
19255 }
19256
19257 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
19258         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19259         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
19260         return tag_ptr(ret_conv, true);
19261 }
19262 int64_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint64_t arg) {
19263         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(arg);
19264         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
19265         return ret_conv;
19266 }
19267
19268 uint64_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint64_t orig) {
19269         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(orig);
19270         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19271         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
19272         return tag_ptr(ret_conv, true);
19273 }
19274
19275 uint64_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint64_t o) {
19276         LDKRevokeAndACK o_conv;
19277         o_conv.inner = untag_ptr(o);
19278         o_conv.is_owned = ptr_is_owned(o);
19279         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19280         o_conv = RevokeAndACK_clone(&o_conv);
19281         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19282         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
19283         return tag_ptr(ret_conv, true);
19284 }
19285
19286 uint64_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint64_t e) {
19287         LDKDecodeError e_conv;
19288         e_conv.inner = untag_ptr(e);
19289         e_conv.is_owned = ptr_is_owned(e);
19290         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19291         e_conv = DecodeError_clone(&e_conv);
19292         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19293         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
19294         return tag_ptr(ret_conv, true);
19295 }
19296
19297 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint64_t o) {
19298         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(o);
19299         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
19300         return ret_conv;
19301 }
19302
19303 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint64_t _res) {
19304         if (!ptr_is_owned(_res)) return;
19305         void* _res_ptr = untag_ptr(_res);
19306         CHECK_ACCESS(_res_ptr);
19307         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
19308         FREE(untag_ptr(_res));
19309         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
19310 }
19311
19312 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
19313         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19314         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
19315         return tag_ptr(ret_conv, true);
19316 }
19317 int64_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint64_t arg) {
19318         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(arg);
19319         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
19320         return ret_conv;
19321 }
19322
19323 uint64_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint64_t orig) {
19324         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(orig);
19325         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19326         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
19327         return tag_ptr(ret_conv, true);
19328 }
19329
19330 uint64_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint64_t o) {
19331         LDKShutdown o_conv;
19332         o_conv.inner = untag_ptr(o);
19333         o_conv.is_owned = ptr_is_owned(o);
19334         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19335         o_conv = Shutdown_clone(&o_conv);
19336         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19337         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
19338         return tag_ptr(ret_conv, true);
19339 }
19340
19341 uint64_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint64_t e) {
19342         LDKDecodeError e_conv;
19343         e_conv.inner = untag_ptr(e);
19344         e_conv.is_owned = ptr_is_owned(e);
19345         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19346         e_conv = DecodeError_clone(&e_conv);
19347         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19348         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
19349         return tag_ptr(ret_conv, true);
19350 }
19351
19352 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint64_t o) {
19353         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(o);
19354         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
19355         return ret_conv;
19356 }
19357
19358 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint64_t _res) {
19359         if (!ptr_is_owned(_res)) return;
19360         void* _res_ptr = untag_ptr(_res);
19361         CHECK_ACCESS(_res_ptr);
19362         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
19363         FREE(untag_ptr(_res));
19364         CResult_ShutdownDecodeErrorZ_free(_res_conv);
19365 }
19366
19367 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
19368         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19369         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
19370         return tag_ptr(ret_conv, true);
19371 }
19372 int64_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint64_t arg) {
19373         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(arg);
19374         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
19375         return ret_conv;
19376 }
19377
19378 uint64_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint64_t orig) {
19379         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(orig);
19380         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19381         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
19382         return tag_ptr(ret_conv, true);
19383 }
19384
19385 uint64_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint64_t o) {
19386         LDKUpdateFailHTLC o_conv;
19387         o_conv.inner = untag_ptr(o);
19388         o_conv.is_owned = ptr_is_owned(o);
19389         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19390         o_conv = UpdateFailHTLC_clone(&o_conv);
19391         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19392         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
19393         return tag_ptr(ret_conv, true);
19394 }
19395
19396 uint64_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint64_t e) {
19397         LDKDecodeError e_conv;
19398         e_conv.inner = untag_ptr(e);
19399         e_conv.is_owned = ptr_is_owned(e);
19400         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19401         e_conv = DecodeError_clone(&e_conv);
19402         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19403         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
19404         return tag_ptr(ret_conv, true);
19405 }
19406
19407 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint64_t o) {
19408         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(o);
19409         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
19410         return ret_conv;
19411 }
19412
19413 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint64_t _res) {
19414         if (!ptr_is_owned(_res)) return;
19415         void* _res_ptr = untag_ptr(_res);
19416         CHECK_ACCESS(_res_ptr);
19417         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
19418         FREE(untag_ptr(_res));
19419         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
19420 }
19421
19422 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
19423         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19424         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
19425         return tag_ptr(ret_conv, true);
19426 }
19427 int64_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint64_t arg) {
19428         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(arg);
19429         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
19430         return ret_conv;
19431 }
19432
19433 uint64_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint64_t orig) {
19434         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(orig);
19435         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19436         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
19437         return tag_ptr(ret_conv, true);
19438 }
19439
19440 uint64_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint64_t o) {
19441         LDKUpdateFailMalformedHTLC o_conv;
19442         o_conv.inner = untag_ptr(o);
19443         o_conv.is_owned = ptr_is_owned(o);
19444         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19445         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
19446         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19447         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
19448         return tag_ptr(ret_conv, true);
19449 }
19450
19451 uint64_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint64_t e) {
19452         LDKDecodeError e_conv;
19453         e_conv.inner = untag_ptr(e);
19454         e_conv.is_owned = ptr_is_owned(e);
19455         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19456         e_conv = DecodeError_clone(&e_conv);
19457         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19458         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
19459         return tag_ptr(ret_conv, true);
19460 }
19461
19462 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint64_t o) {
19463         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(o);
19464         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
19465         return ret_conv;
19466 }
19467
19468 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint64_t _res) {
19469         if (!ptr_is_owned(_res)) return;
19470         void* _res_ptr = untag_ptr(_res);
19471         CHECK_ACCESS(_res_ptr);
19472         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
19473         FREE(untag_ptr(_res));
19474         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
19475 }
19476
19477 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
19478         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19479         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
19480         return tag_ptr(ret_conv, true);
19481 }
19482 int64_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint64_t arg) {
19483         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(arg);
19484         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
19485         return ret_conv;
19486 }
19487
19488 uint64_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint64_t orig) {
19489         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(orig);
19490         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19491         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
19492         return tag_ptr(ret_conv, true);
19493 }
19494
19495 uint64_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint64_t o) {
19496         LDKUpdateFee o_conv;
19497         o_conv.inner = untag_ptr(o);
19498         o_conv.is_owned = ptr_is_owned(o);
19499         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19500         o_conv = UpdateFee_clone(&o_conv);
19501         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19502         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
19503         return tag_ptr(ret_conv, true);
19504 }
19505
19506 uint64_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint64_t e) {
19507         LDKDecodeError e_conv;
19508         e_conv.inner = untag_ptr(e);
19509         e_conv.is_owned = ptr_is_owned(e);
19510         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19511         e_conv = DecodeError_clone(&e_conv);
19512         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19513         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
19514         return tag_ptr(ret_conv, true);
19515 }
19516
19517 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint64_t o) {
19518         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(o);
19519         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
19520         return ret_conv;
19521 }
19522
19523 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint64_t _res) {
19524         if (!ptr_is_owned(_res)) return;
19525         void* _res_ptr = untag_ptr(_res);
19526         CHECK_ACCESS(_res_ptr);
19527         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
19528         FREE(untag_ptr(_res));
19529         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
19530 }
19531
19532 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
19533         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19534         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
19535         return tag_ptr(ret_conv, true);
19536 }
19537 int64_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint64_t arg) {
19538         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(arg);
19539         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
19540         return ret_conv;
19541 }
19542
19543 uint64_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint64_t orig) {
19544         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(orig);
19545         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19546         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
19547         return tag_ptr(ret_conv, true);
19548 }
19549
19550 uint64_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint64_t o) {
19551         LDKUpdateFulfillHTLC o_conv;
19552         o_conv.inner = untag_ptr(o);
19553         o_conv.is_owned = ptr_is_owned(o);
19554         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19555         o_conv = UpdateFulfillHTLC_clone(&o_conv);
19556         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19557         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
19558         return tag_ptr(ret_conv, true);
19559 }
19560
19561 uint64_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint64_t e) {
19562         LDKDecodeError e_conv;
19563         e_conv.inner = untag_ptr(e);
19564         e_conv.is_owned = ptr_is_owned(e);
19565         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19566         e_conv = DecodeError_clone(&e_conv);
19567         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19568         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
19569         return tag_ptr(ret_conv, true);
19570 }
19571
19572 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint64_t o) {
19573         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(o);
19574         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
19575         return ret_conv;
19576 }
19577
19578 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint64_t _res) {
19579         if (!ptr_is_owned(_res)) return;
19580         void* _res_ptr = untag_ptr(_res);
19581         CHECK_ACCESS(_res_ptr);
19582         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
19583         FREE(untag_ptr(_res));
19584         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
19585 }
19586
19587 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
19588         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19589         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
19590         return tag_ptr(ret_conv, true);
19591 }
19592 int64_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint64_t arg) {
19593         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(arg);
19594         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
19595         return ret_conv;
19596 }
19597
19598 uint64_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint64_t orig) {
19599         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(orig);
19600         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19601         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
19602         return tag_ptr(ret_conv, true);
19603 }
19604
19605 uint64_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint64_t o) {
19606         LDKUpdateAddHTLC o_conv;
19607         o_conv.inner = untag_ptr(o);
19608         o_conv.is_owned = ptr_is_owned(o);
19609         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19610         o_conv = UpdateAddHTLC_clone(&o_conv);
19611         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19612         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
19613         return tag_ptr(ret_conv, true);
19614 }
19615
19616 uint64_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint64_t e) {
19617         LDKDecodeError e_conv;
19618         e_conv.inner = untag_ptr(e);
19619         e_conv.is_owned = ptr_is_owned(e);
19620         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19621         e_conv = DecodeError_clone(&e_conv);
19622         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19623         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
19624         return tag_ptr(ret_conv, true);
19625 }
19626
19627 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint64_t o) {
19628         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(o);
19629         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
19630         return ret_conv;
19631 }
19632
19633 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint64_t _res) {
19634         if (!ptr_is_owned(_res)) return;
19635         void* _res_ptr = untag_ptr(_res);
19636         CHECK_ACCESS(_res_ptr);
19637         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
19638         FREE(untag_ptr(_res));
19639         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
19640 }
19641
19642 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
19643         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19644         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
19645         return tag_ptr(ret_conv, true);
19646 }
19647 int64_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint64_t arg) {
19648         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(arg);
19649         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
19650         return ret_conv;
19651 }
19652
19653 uint64_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint64_t orig) {
19654         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(orig);
19655         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19656         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
19657         return tag_ptr(ret_conv, true);
19658 }
19659
19660 uint64_t  __attribute__((export_name("TS_CResult_OnionMessageDecodeErrorZ_ok"))) TS_CResult_OnionMessageDecodeErrorZ_ok(uint64_t o) {
19661         LDKOnionMessage o_conv;
19662         o_conv.inner = untag_ptr(o);
19663         o_conv.is_owned = ptr_is_owned(o);
19664         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19665         o_conv = OnionMessage_clone(&o_conv);
19666         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
19667         *ret_conv = CResult_OnionMessageDecodeErrorZ_ok(o_conv);
19668         return tag_ptr(ret_conv, true);
19669 }
19670
19671 uint64_t  __attribute__((export_name("TS_CResult_OnionMessageDecodeErrorZ_err"))) TS_CResult_OnionMessageDecodeErrorZ_err(uint64_t e) {
19672         LDKDecodeError e_conv;
19673         e_conv.inner = untag_ptr(e);
19674         e_conv.is_owned = ptr_is_owned(e);
19675         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19676         e_conv = DecodeError_clone(&e_conv);
19677         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
19678         *ret_conv = CResult_OnionMessageDecodeErrorZ_err(e_conv);
19679         return tag_ptr(ret_conv, true);
19680 }
19681
19682 jboolean  __attribute__((export_name("TS_CResult_OnionMessageDecodeErrorZ_is_ok"))) TS_CResult_OnionMessageDecodeErrorZ_is_ok(uint64_t o) {
19683         LDKCResult_OnionMessageDecodeErrorZ* o_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(o);
19684         jboolean ret_conv = CResult_OnionMessageDecodeErrorZ_is_ok(o_conv);
19685         return ret_conv;
19686 }
19687
19688 void  __attribute__((export_name("TS_CResult_OnionMessageDecodeErrorZ_free"))) TS_CResult_OnionMessageDecodeErrorZ_free(uint64_t _res) {
19689         if (!ptr_is_owned(_res)) return;
19690         void* _res_ptr = untag_ptr(_res);
19691         CHECK_ACCESS(_res_ptr);
19692         LDKCResult_OnionMessageDecodeErrorZ _res_conv = *(LDKCResult_OnionMessageDecodeErrorZ*)(_res_ptr);
19693         FREE(untag_ptr(_res));
19694         CResult_OnionMessageDecodeErrorZ_free(_res_conv);
19695 }
19696
19697 static inline uint64_t CResult_OnionMessageDecodeErrorZ_clone_ptr(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR arg) {
19698         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
19699         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(arg);
19700         return tag_ptr(ret_conv, true);
19701 }
19702 int64_t  __attribute__((export_name("TS_CResult_OnionMessageDecodeErrorZ_clone_ptr"))) TS_CResult_OnionMessageDecodeErrorZ_clone_ptr(uint64_t arg) {
19703         LDKCResult_OnionMessageDecodeErrorZ* arg_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(arg);
19704         int64_t ret_conv = CResult_OnionMessageDecodeErrorZ_clone_ptr(arg_conv);
19705         return ret_conv;
19706 }
19707
19708 uint64_t  __attribute__((export_name("TS_CResult_OnionMessageDecodeErrorZ_clone"))) TS_CResult_OnionMessageDecodeErrorZ_clone(uint64_t orig) {
19709         LDKCResult_OnionMessageDecodeErrorZ* orig_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(orig);
19710         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
19711         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(orig_conv);
19712         return tag_ptr(ret_conv, true);
19713 }
19714
19715 uint64_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint64_t o) {
19716         LDKPing o_conv;
19717         o_conv.inner = untag_ptr(o);
19718         o_conv.is_owned = ptr_is_owned(o);
19719         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19720         o_conv = Ping_clone(&o_conv);
19721         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19722         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
19723         return tag_ptr(ret_conv, true);
19724 }
19725
19726 uint64_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint64_t e) {
19727         LDKDecodeError e_conv;
19728         e_conv.inner = untag_ptr(e);
19729         e_conv.is_owned = ptr_is_owned(e);
19730         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19731         e_conv = DecodeError_clone(&e_conv);
19732         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19733         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
19734         return tag_ptr(ret_conv, true);
19735 }
19736
19737 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint64_t o) {
19738         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(o);
19739         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
19740         return ret_conv;
19741 }
19742
19743 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint64_t _res) {
19744         if (!ptr_is_owned(_res)) return;
19745         void* _res_ptr = untag_ptr(_res);
19746         CHECK_ACCESS(_res_ptr);
19747         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
19748         FREE(untag_ptr(_res));
19749         CResult_PingDecodeErrorZ_free(_res_conv);
19750 }
19751
19752 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
19753         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19754         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
19755         return tag_ptr(ret_conv, true);
19756 }
19757 int64_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint64_t arg) {
19758         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(arg);
19759         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
19760         return ret_conv;
19761 }
19762
19763 uint64_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint64_t orig) {
19764         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(orig);
19765         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19766         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
19767         return tag_ptr(ret_conv, true);
19768 }
19769
19770 uint64_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint64_t o) {
19771         LDKPong o_conv;
19772         o_conv.inner = untag_ptr(o);
19773         o_conv.is_owned = ptr_is_owned(o);
19774         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19775         o_conv = Pong_clone(&o_conv);
19776         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19777         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
19778         return tag_ptr(ret_conv, true);
19779 }
19780
19781 uint64_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint64_t e) {
19782         LDKDecodeError e_conv;
19783         e_conv.inner = untag_ptr(e);
19784         e_conv.is_owned = ptr_is_owned(e);
19785         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19786         e_conv = DecodeError_clone(&e_conv);
19787         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19788         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
19789         return tag_ptr(ret_conv, true);
19790 }
19791
19792 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint64_t o) {
19793         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(o);
19794         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
19795         return ret_conv;
19796 }
19797
19798 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint64_t _res) {
19799         if (!ptr_is_owned(_res)) return;
19800         void* _res_ptr = untag_ptr(_res);
19801         CHECK_ACCESS(_res_ptr);
19802         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
19803         FREE(untag_ptr(_res));
19804         CResult_PongDecodeErrorZ_free(_res_conv);
19805 }
19806
19807 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
19808         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19809         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
19810         return tag_ptr(ret_conv, true);
19811 }
19812 int64_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint64_t arg) {
19813         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(arg);
19814         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
19815         return ret_conv;
19816 }
19817
19818 uint64_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint64_t orig) {
19819         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(orig);
19820         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19821         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
19822         return tag_ptr(ret_conv, true);
19823 }
19824
19825 uint64_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint64_t o) {
19826         LDKUnsignedChannelAnnouncement o_conv;
19827         o_conv.inner = untag_ptr(o);
19828         o_conv.is_owned = ptr_is_owned(o);
19829         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19830         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
19831         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19832         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
19833         return tag_ptr(ret_conv, true);
19834 }
19835
19836 uint64_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint64_t e) {
19837         LDKDecodeError e_conv;
19838         e_conv.inner = untag_ptr(e);
19839         e_conv.is_owned = ptr_is_owned(e);
19840         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19841         e_conv = DecodeError_clone(&e_conv);
19842         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19843         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
19844         return tag_ptr(ret_conv, true);
19845 }
19846
19847 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint64_t o) {
19848         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
19849         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19850         return ret_conv;
19851 }
19852
19853 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint64_t _res) {
19854         if (!ptr_is_owned(_res)) return;
19855         void* _res_ptr = untag_ptr(_res);
19856         CHECK_ACCESS(_res_ptr);
19857         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19858         FREE(untag_ptr(_res));
19859         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
19860 }
19861
19862 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19863         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19864         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
19865         return tag_ptr(ret_conv, true);
19866 }
19867 int64_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint64_t arg) {
19868         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
19869         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19870         return ret_conv;
19871 }
19872
19873 uint64_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint64_t orig) {
19874         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
19875         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19876         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19877         return tag_ptr(ret_conv, true);
19878 }
19879
19880 uint64_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint64_t o) {
19881         LDKChannelAnnouncement o_conv;
19882         o_conv.inner = untag_ptr(o);
19883         o_conv.is_owned = ptr_is_owned(o);
19884         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19885         o_conv = ChannelAnnouncement_clone(&o_conv);
19886         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19887         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
19888         return tag_ptr(ret_conv, true);
19889 }
19890
19891 uint64_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint64_t e) {
19892         LDKDecodeError e_conv;
19893         e_conv.inner = untag_ptr(e);
19894         e_conv.is_owned = ptr_is_owned(e);
19895         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19896         e_conv = DecodeError_clone(&e_conv);
19897         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19898         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
19899         return tag_ptr(ret_conv, true);
19900 }
19901
19902 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint64_t o) {
19903         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
19904         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19905         return ret_conv;
19906 }
19907
19908 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint64_t _res) {
19909         if (!ptr_is_owned(_res)) return;
19910         void* _res_ptr = untag_ptr(_res);
19911         CHECK_ACCESS(_res_ptr);
19912         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19913         FREE(untag_ptr(_res));
19914         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
19915 }
19916
19917 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19918         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19919         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
19920         return tag_ptr(ret_conv, true);
19921 }
19922 int64_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint64_t arg) {
19923         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
19924         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19925         return ret_conv;
19926 }
19927
19928 uint64_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint64_t orig) {
19929         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
19930         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19931         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19932         return tag_ptr(ret_conv, true);
19933 }
19934
19935 uint64_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint64_t o) {
19936         LDKUnsignedChannelUpdate o_conv;
19937         o_conv.inner = untag_ptr(o);
19938         o_conv.is_owned = ptr_is_owned(o);
19939         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19940         o_conv = UnsignedChannelUpdate_clone(&o_conv);
19941         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19942         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
19943         return tag_ptr(ret_conv, true);
19944 }
19945
19946 uint64_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint64_t e) {
19947         LDKDecodeError e_conv;
19948         e_conv.inner = untag_ptr(e);
19949         e_conv.is_owned = ptr_is_owned(e);
19950         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19951         e_conv = DecodeError_clone(&e_conv);
19952         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19953         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
19954         return tag_ptr(ret_conv, true);
19955 }
19956
19957 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint64_t o) {
19958         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(o);
19959         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
19960         return ret_conv;
19961 }
19962
19963 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint64_t _res) {
19964         if (!ptr_is_owned(_res)) return;
19965         void* _res_ptr = untag_ptr(_res);
19966         CHECK_ACCESS(_res_ptr);
19967         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
19968         FREE(untag_ptr(_res));
19969         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
19970 }
19971
19972 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19973         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19974         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
19975         return tag_ptr(ret_conv, true);
19976 }
19977 int64_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint64_t arg) {
19978         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(arg);
19979         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
19980         return ret_conv;
19981 }
19982
19983 uint64_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint64_t orig) {
19984         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(orig);
19985         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19986         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
19987         return tag_ptr(ret_conv, true);
19988 }
19989
19990 uint64_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint64_t o) {
19991         LDKChannelUpdate o_conv;
19992         o_conv.inner = untag_ptr(o);
19993         o_conv.is_owned = ptr_is_owned(o);
19994         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19995         o_conv = ChannelUpdate_clone(&o_conv);
19996         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19997         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
19998         return tag_ptr(ret_conv, true);
19999 }
20000
20001 uint64_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint64_t e) {
20002         LDKDecodeError e_conv;
20003         e_conv.inner = untag_ptr(e);
20004         e_conv.is_owned = ptr_is_owned(e);
20005         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20006         e_conv = DecodeError_clone(&e_conv);
20007         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20008         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
20009         return tag_ptr(ret_conv, true);
20010 }
20011
20012 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint64_t o) {
20013         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(o);
20014         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
20015         return ret_conv;
20016 }
20017
20018 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint64_t _res) {
20019         if (!ptr_is_owned(_res)) return;
20020         void* _res_ptr = untag_ptr(_res);
20021         CHECK_ACCESS(_res_ptr);
20022         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
20023         FREE(untag_ptr(_res));
20024         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
20025 }
20026
20027 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
20028         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20029         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
20030         return tag_ptr(ret_conv, true);
20031 }
20032 int64_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint64_t arg) {
20033         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(arg);
20034         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
20035         return ret_conv;
20036 }
20037
20038 uint64_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint64_t orig) {
20039         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(orig);
20040         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20041         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
20042         return tag_ptr(ret_conv, true);
20043 }
20044
20045 uint64_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint64_t o) {
20046         LDKErrorMessage o_conv;
20047         o_conv.inner = untag_ptr(o);
20048         o_conv.is_owned = ptr_is_owned(o);
20049         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20050         o_conv = ErrorMessage_clone(&o_conv);
20051         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20052         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
20053         return tag_ptr(ret_conv, true);
20054 }
20055
20056 uint64_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint64_t e) {
20057         LDKDecodeError e_conv;
20058         e_conv.inner = untag_ptr(e);
20059         e_conv.is_owned = ptr_is_owned(e);
20060         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20061         e_conv = DecodeError_clone(&e_conv);
20062         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20063         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
20064         return tag_ptr(ret_conv, true);
20065 }
20066
20067 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint64_t o) {
20068         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(o);
20069         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
20070         return ret_conv;
20071 }
20072
20073 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint64_t _res) {
20074         if (!ptr_is_owned(_res)) return;
20075         void* _res_ptr = untag_ptr(_res);
20076         CHECK_ACCESS(_res_ptr);
20077         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
20078         FREE(untag_ptr(_res));
20079         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
20080 }
20081
20082 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
20083         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20084         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
20085         return tag_ptr(ret_conv, true);
20086 }
20087 int64_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint64_t arg) {
20088         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(arg);
20089         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
20090         return ret_conv;
20091 }
20092
20093 uint64_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint64_t orig) {
20094         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(orig);
20095         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20096         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
20097         return tag_ptr(ret_conv, true);
20098 }
20099
20100 uint64_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_ok"))) TS_CResult_WarningMessageDecodeErrorZ_ok(uint64_t o) {
20101         LDKWarningMessage o_conv;
20102         o_conv.inner = untag_ptr(o);
20103         o_conv.is_owned = ptr_is_owned(o);
20104         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20105         o_conv = WarningMessage_clone(&o_conv);
20106         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20107         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
20108         return tag_ptr(ret_conv, true);
20109 }
20110
20111 uint64_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_err"))) TS_CResult_WarningMessageDecodeErrorZ_err(uint64_t e) {
20112         LDKDecodeError e_conv;
20113         e_conv.inner = untag_ptr(e);
20114         e_conv.is_owned = ptr_is_owned(e);
20115         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20116         e_conv = DecodeError_clone(&e_conv);
20117         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20118         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
20119         return tag_ptr(ret_conv, true);
20120 }
20121
20122 jboolean  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_is_ok"))) TS_CResult_WarningMessageDecodeErrorZ_is_ok(uint64_t o) {
20123         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(o);
20124         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
20125         return ret_conv;
20126 }
20127
20128 void  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_free"))) TS_CResult_WarningMessageDecodeErrorZ_free(uint64_t _res) {
20129         if (!ptr_is_owned(_res)) return;
20130         void* _res_ptr = untag_ptr(_res);
20131         CHECK_ACCESS(_res_ptr);
20132         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
20133         FREE(untag_ptr(_res));
20134         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
20135 }
20136
20137 static inline uint64_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
20138         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20139         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
20140         return tag_ptr(ret_conv, true);
20141 }
20142 int64_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone_ptr"))) TS_CResult_WarningMessageDecodeErrorZ_clone_ptr(uint64_t arg) {
20143         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(arg);
20144         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
20145         return ret_conv;
20146 }
20147
20148 uint64_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone"))) TS_CResult_WarningMessageDecodeErrorZ_clone(uint64_t orig) {
20149         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(orig);
20150         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20151         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
20152         return tag_ptr(ret_conv, true);
20153 }
20154
20155 uint64_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint64_t o) {
20156         LDKUnsignedNodeAnnouncement o_conv;
20157         o_conv.inner = untag_ptr(o);
20158         o_conv.is_owned = ptr_is_owned(o);
20159         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20160         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
20161         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20162         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
20163         return tag_ptr(ret_conv, true);
20164 }
20165
20166 uint64_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint64_t e) {
20167         LDKDecodeError e_conv;
20168         e_conv.inner = untag_ptr(e);
20169         e_conv.is_owned = ptr_is_owned(e);
20170         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20171         e_conv = DecodeError_clone(&e_conv);
20172         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20173         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
20174         return tag_ptr(ret_conv, true);
20175 }
20176
20177 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint64_t o) {
20178         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(o);
20179         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
20180         return ret_conv;
20181 }
20182
20183 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint64_t _res) {
20184         if (!ptr_is_owned(_res)) return;
20185         void* _res_ptr = untag_ptr(_res);
20186         CHECK_ACCESS(_res_ptr);
20187         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
20188         FREE(untag_ptr(_res));
20189         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
20190 }
20191
20192 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
20193         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20194         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
20195         return tag_ptr(ret_conv, true);
20196 }
20197 int64_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint64_t arg) {
20198         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
20199         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
20200         return ret_conv;
20201 }
20202
20203 uint64_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint64_t orig) {
20204         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
20205         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20206         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
20207         return tag_ptr(ret_conv, true);
20208 }
20209
20210 uint64_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint64_t o) {
20211         LDKNodeAnnouncement o_conv;
20212         o_conv.inner = untag_ptr(o);
20213         o_conv.is_owned = ptr_is_owned(o);
20214         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20215         o_conv = NodeAnnouncement_clone(&o_conv);
20216         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20217         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
20218         return tag_ptr(ret_conv, true);
20219 }
20220
20221 uint64_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint64_t e) {
20222         LDKDecodeError e_conv;
20223         e_conv.inner = untag_ptr(e);
20224         e_conv.is_owned = ptr_is_owned(e);
20225         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20226         e_conv = DecodeError_clone(&e_conv);
20227         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20228         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
20229         return tag_ptr(ret_conv, true);
20230 }
20231
20232 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint64_t o) {
20233         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(o);
20234         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
20235         return ret_conv;
20236 }
20237
20238 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint64_t _res) {
20239         if (!ptr_is_owned(_res)) return;
20240         void* _res_ptr = untag_ptr(_res);
20241         CHECK_ACCESS(_res_ptr);
20242         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
20243         FREE(untag_ptr(_res));
20244         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
20245 }
20246
20247 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
20248         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20249         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
20250         return tag_ptr(ret_conv, true);
20251 }
20252 int64_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint64_t arg) {
20253         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
20254         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
20255         return ret_conv;
20256 }
20257
20258 uint64_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint64_t orig) {
20259         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
20260         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20261         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
20262         return tag_ptr(ret_conv, true);
20263 }
20264
20265 uint64_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint64_t o) {
20266         LDKQueryShortChannelIds o_conv;
20267         o_conv.inner = untag_ptr(o);
20268         o_conv.is_owned = ptr_is_owned(o);
20269         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20270         o_conv = QueryShortChannelIds_clone(&o_conv);
20271         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20272         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
20273         return tag_ptr(ret_conv, true);
20274 }
20275
20276 uint64_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint64_t e) {
20277         LDKDecodeError e_conv;
20278         e_conv.inner = untag_ptr(e);
20279         e_conv.is_owned = ptr_is_owned(e);
20280         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20281         e_conv = DecodeError_clone(&e_conv);
20282         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20283         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
20284         return tag_ptr(ret_conv, true);
20285 }
20286
20287 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint64_t o) {
20288         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(o);
20289         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
20290         return ret_conv;
20291 }
20292
20293 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint64_t _res) {
20294         if (!ptr_is_owned(_res)) return;
20295         void* _res_ptr = untag_ptr(_res);
20296         CHECK_ACCESS(_res_ptr);
20297         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
20298         FREE(untag_ptr(_res));
20299         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
20300 }
20301
20302 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
20303         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20304         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
20305         return tag_ptr(ret_conv, true);
20306 }
20307 int64_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint64_t arg) {
20308         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(arg);
20309         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
20310         return ret_conv;
20311 }
20312
20313 uint64_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint64_t orig) {
20314         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(orig);
20315         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20316         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
20317         return tag_ptr(ret_conv, true);
20318 }
20319
20320 uint64_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint64_t o) {
20321         LDKReplyShortChannelIdsEnd o_conv;
20322         o_conv.inner = untag_ptr(o);
20323         o_conv.is_owned = ptr_is_owned(o);
20324         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20325         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
20326         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20327         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
20328         return tag_ptr(ret_conv, true);
20329 }
20330
20331 uint64_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint64_t e) {
20332         LDKDecodeError e_conv;
20333         e_conv.inner = untag_ptr(e);
20334         e_conv.is_owned = ptr_is_owned(e);
20335         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20336         e_conv = DecodeError_clone(&e_conv);
20337         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20338         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
20339         return tag_ptr(ret_conv, true);
20340 }
20341
20342 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint64_t o) {
20343         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(o);
20344         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
20345         return ret_conv;
20346 }
20347
20348 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint64_t _res) {
20349         if (!ptr_is_owned(_res)) return;
20350         void* _res_ptr = untag_ptr(_res);
20351         CHECK_ACCESS(_res_ptr);
20352         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
20353         FREE(untag_ptr(_res));
20354         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
20355 }
20356
20357 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
20358         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20359         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
20360         return tag_ptr(ret_conv, true);
20361 }
20362 int64_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint64_t arg) {
20363         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(arg);
20364         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
20365         return ret_conv;
20366 }
20367
20368 uint64_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint64_t orig) {
20369         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(orig);
20370         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20371         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
20372         return tag_ptr(ret_conv, true);
20373 }
20374
20375 uint64_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint64_t o) {
20376         LDKQueryChannelRange o_conv;
20377         o_conv.inner = untag_ptr(o);
20378         o_conv.is_owned = ptr_is_owned(o);
20379         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20380         o_conv = QueryChannelRange_clone(&o_conv);
20381         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20382         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
20383         return tag_ptr(ret_conv, true);
20384 }
20385
20386 uint64_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint64_t e) {
20387         LDKDecodeError e_conv;
20388         e_conv.inner = untag_ptr(e);
20389         e_conv.is_owned = ptr_is_owned(e);
20390         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20391         e_conv = DecodeError_clone(&e_conv);
20392         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20393         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
20394         return tag_ptr(ret_conv, true);
20395 }
20396
20397 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint64_t o) {
20398         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(o);
20399         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
20400         return ret_conv;
20401 }
20402
20403 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint64_t _res) {
20404         if (!ptr_is_owned(_res)) return;
20405         void* _res_ptr = untag_ptr(_res);
20406         CHECK_ACCESS(_res_ptr);
20407         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
20408         FREE(untag_ptr(_res));
20409         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
20410 }
20411
20412 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
20413         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20414         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
20415         return tag_ptr(ret_conv, true);
20416 }
20417 int64_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint64_t arg) {
20418         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(arg);
20419         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
20420         return ret_conv;
20421 }
20422
20423 uint64_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint64_t orig) {
20424         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(orig);
20425         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20426         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
20427         return tag_ptr(ret_conv, true);
20428 }
20429
20430 uint64_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint64_t o) {
20431         LDKReplyChannelRange o_conv;
20432         o_conv.inner = untag_ptr(o);
20433         o_conv.is_owned = ptr_is_owned(o);
20434         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20435         o_conv = ReplyChannelRange_clone(&o_conv);
20436         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20437         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
20438         return tag_ptr(ret_conv, true);
20439 }
20440
20441 uint64_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint64_t e) {
20442         LDKDecodeError e_conv;
20443         e_conv.inner = untag_ptr(e);
20444         e_conv.is_owned = ptr_is_owned(e);
20445         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20446         e_conv = DecodeError_clone(&e_conv);
20447         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20448         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
20449         return tag_ptr(ret_conv, true);
20450 }
20451
20452 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint64_t o) {
20453         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(o);
20454         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
20455         return ret_conv;
20456 }
20457
20458 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint64_t _res) {
20459         if (!ptr_is_owned(_res)) return;
20460         void* _res_ptr = untag_ptr(_res);
20461         CHECK_ACCESS(_res_ptr);
20462         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
20463         FREE(untag_ptr(_res));
20464         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
20465 }
20466
20467 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
20468         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20469         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
20470         return tag_ptr(ret_conv, true);
20471 }
20472 int64_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint64_t arg) {
20473         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(arg);
20474         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
20475         return ret_conv;
20476 }
20477
20478 uint64_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint64_t orig) {
20479         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(orig);
20480         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20481         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
20482         return tag_ptr(ret_conv, true);
20483 }
20484
20485 uint64_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint64_t o) {
20486         LDKGossipTimestampFilter o_conv;
20487         o_conv.inner = untag_ptr(o);
20488         o_conv.is_owned = ptr_is_owned(o);
20489         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20490         o_conv = GossipTimestampFilter_clone(&o_conv);
20491         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20492         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
20493         return tag_ptr(ret_conv, true);
20494 }
20495
20496 uint64_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint64_t e) {
20497         LDKDecodeError e_conv;
20498         e_conv.inner = untag_ptr(e);
20499         e_conv.is_owned = ptr_is_owned(e);
20500         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20501         e_conv = DecodeError_clone(&e_conv);
20502         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20503         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
20504         return tag_ptr(ret_conv, true);
20505 }
20506
20507 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint64_t o) {
20508         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(o);
20509         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
20510         return ret_conv;
20511 }
20512
20513 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint64_t _res) {
20514         if (!ptr_is_owned(_res)) return;
20515         void* _res_ptr = untag_ptr(_res);
20516         CHECK_ACCESS(_res_ptr);
20517         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
20518         FREE(untag_ptr(_res));
20519         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
20520 }
20521
20522 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
20523         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20524         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
20525         return tag_ptr(ret_conv, true);
20526 }
20527 int64_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint64_t arg) {
20528         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(arg);
20529         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
20530         return ret_conv;
20531 }
20532
20533 uint64_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint64_t orig) {
20534         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(orig);
20535         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20536         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
20537         return tag_ptr(ret_conv, true);
20538 }
20539
20540 uint64_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint64_t o) {
20541         LDKInvoice o_conv;
20542         o_conv.inner = untag_ptr(o);
20543         o_conv.is_owned = ptr_is_owned(o);
20544         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20545         o_conv = Invoice_clone(&o_conv);
20546         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20547         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
20548         return tag_ptr(ret_conv, true);
20549 }
20550
20551 uint64_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint64_t e) {
20552         void* e_ptr = untag_ptr(e);
20553         CHECK_ACCESS(e_ptr);
20554         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
20555         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)untag_ptr(e));
20556         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20557         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
20558         return tag_ptr(ret_conv, true);
20559 }
20560
20561 jboolean  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_is_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint64_t o) {
20562         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(o);
20563         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
20564         return ret_conv;
20565 }
20566
20567 void  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_free"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint64_t _res) {
20568         if (!ptr_is_owned(_res)) return;
20569         void* _res_ptr = untag_ptr(_res);
20570         CHECK_ACCESS(_res_ptr);
20571         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
20572         FREE(untag_ptr(_res));
20573         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
20574 }
20575
20576 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
20577         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20578         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
20579         return tag_ptr(ret_conv, true);
20580 }
20581 int64_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint64_t arg) {
20582         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(arg);
20583         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
20584         return ret_conv;
20585 }
20586
20587 uint64_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint64_t orig) {
20588         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(orig);
20589         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20590         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
20591         return tag_ptr(ret_conv, true);
20592 }
20593
20594 uint64_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint64_t o) {
20595         void* o_ptr = untag_ptr(o);
20596         CHECK_ACCESS(o_ptr);
20597         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
20598         if (o_conv.free == LDKFilter_JCalls_free) {
20599                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20600                 LDKFilter_JCalls_cloned(&o_conv);
20601         }
20602         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
20603         *ret_copy = COption_FilterZ_some(o_conv);
20604         uint64_t ret_ref = tag_ptr(ret_copy, true);
20605         return ret_ref;
20606 }
20607
20608 uint64_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
20609         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
20610         *ret_copy = COption_FilterZ_none();
20611         uint64_t ret_ref = tag_ptr(ret_copy, true);
20612         return ret_ref;
20613 }
20614
20615 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint64_t _res) {
20616         if (!ptr_is_owned(_res)) return;
20617         void* _res_ptr = untag_ptr(_res);
20618         CHECK_ACCESS(_res_ptr);
20619         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
20620         FREE(untag_ptr(_res));
20621         COption_FilterZ_free(_res_conv);
20622 }
20623
20624 uint64_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint64_t o) {
20625         LDKLockedChannelMonitor o_conv;
20626         o_conv.inner = untag_ptr(o);
20627         o_conv.is_owned = ptr_is_owned(o);
20628         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20629         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
20630         
20631         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
20632         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
20633         return tag_ptr(ret_conv, true);
20634 }
20635
20636 uint64_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
20637         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
20638         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
20639         return tag_ptr(ret_conv, true);
20640 }
20641
20642 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint64_t o) {
20643         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(o);
20644         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
20645         return ret_conv;
20646 }
20647
20648 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint64_t _res) {
20649         if (!ptr_is_owned(_res)) return;
20650         void* _res_ptr = untag_ptr(_res);
20651         CHECK_ACCESS(_res_ptr);
20652         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
20653         FREE(untag_ptr(_res));
20654         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
20655 }
20656
20657 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint64_tArray _res) {
20658         LDKCVec_OutPointZ _res_constr;
20659         _res_constr.datalen = _res->arr_len;
20660         if (_res_constr.datalen > 0)
20661                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
20662         else
20663                 _res_constr.data = NULL;
20664         uint64_t* _res_vals = _res->elems;
20665         for (size_t k = 0; k < _res_constr.datalen; k++) {
20666                 uint64_t _res_conv_10 = _res_vals[k];
20667                 LDKOutPoint _res_conv_10_conv;
20668                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
20669                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
20670                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
20671                 _res_constr.data[k] = _res_conv_10_conv;
20672         }
20673         FREE(_res);
20674         CVec_OutPointZ_free(_res_constr);
20675 }
20676
20677 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint64_t this_ptr) {
20678         if (!ptr_is_owned(this_ptr)) return;
20679         void* this_ptr_ptr = untag_ptr(this_ptr);
20680         CHECK_ACCESS(this_ptr_ptr);
20681         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
20682         FREE(untag_ptr(this_ptr));
20683         PaymentPurpose_free(this_ptr_conv);
20684 }
20685
20686 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
20687         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20688         *ret_copy = PaymentPurpose_clone(arg);
20689         uint64_t ret_ref = tag_ptr(ret_copy, true);
20690         return ret_ref;
20691 }
20692 int64_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint64_t arg) {
20693         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)untag_ptr(arg);
20694         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
20695         return ret_conv;
20696 }
20697
20698 uint64_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint64_t orig) {
20699         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)untag_ptr(orig);
20700         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20701         *ret_copy = PaymentPurpose_clone(orig_conv);
20702         uint64_t ret_ref = tag_ptr(ret_copy, true);
20703         return ret_ref;
20704 }
20705
20706 uint64_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
20707         LDKThirtyTwoBytes payment_preimage_ref;
20708         CHECK(payment_preimage->arr_len == 32);
20709         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
20710         LDKThirtyTwoBytes payment_secret_ref;
20711         CHECK(payment_secret->arr_len == 32);
20712         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
20713         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20714         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
20715         uint64_t ret_ref = tag_ptr(ret_copy, true);
20716         return ret_ref;
20717 }
20718
20719 uint64_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
20720         LDKThirtyTwoBytes a_ref;
20721         CHECK(a->arr_len == 32);
20722         memcpy(a_ref.data, a->elems, 32); FREE(a);
20723         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20724         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
20725         uint64_t ret_ref = tag_ptr(ret_copy, true);
20726         return ret_ref;
20727 }
20728
20729 int8_tArray  __attribute__((export_name("TS_PaymentPurpose_write"))) TS_PaymentPurpose_write(uint64_t obj) {
20730         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)untag_ptr(obj);
20731         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
20732         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20733         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20734         CVec_u8Z_free(ret_var);
20735         return ret_arr;
20736 }
20737
20738 uint64_t  __attribute__((export_name("TS_PaymentPurpose_read"))) TS_PaymentPurpose_read(int8_tArray ser) {
20739         LDKu8slice ser_ref;
20740         ser_ref.datalen = ser->arr_len;
20741         ser_ref.data = ser->elems;
20742         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
20743         *ret_conv = PaymentPurpose_read(ser_ref);
20744         FREE(ser);
20745         return tag_ptr(ret_conv, true);
20746 }
20747
20748 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint64_t this_ptr) {
20749         if (!ptr_is_owned(this_ptr)) return;
20750         void* this_ptr_ptr = untag_ptr(this_ptr);
20751         CHECK_ACCESS(this_ptr_ptr);
20752         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
20753         FREE(untag_ptr(this_ptr));
20754         ClosureReason_free(this_ptr_conv);
20755 }
20756
20757 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
20758         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20759         *ret_copy = ClosureReason_clone(arg);
20760         uint64_t ret_ref = tag_ptr(ret_copy, true);
20761         return ret_ref;
20762 }
20763 int64_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint64_t arg) {
20764         LDKClosureReason* arg_conv = (LDKClosureReason*)untag_ptr(arg);
20765         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
20766         return ret_conv;
20767 }
20768
20769 uint64_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint64_t orig) {
20770         LDKClosureReason* orig_conv = (LDKClosureReason*)untag_ptr(orig);
20771         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20772         *ret_copy = ClosureReason_clone(orig_conv);
20773         uint64_t ret_ref = tag_ptr(ret_copy, true);
20774         return ret_ref;
20775 }
20776
20777 uint64_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
20778         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
20779         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20780         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
20781         uint64_t ret_ref = tag_ptr(ret_copy, true);
20782         return ret_ref;
20783 }
20784
20785 uint64_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
20786         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20787         *ret_copy = ClosureReason_holder_force_closed();
20788         uint64_t ret_ref = tag_ptr(ret_copy, true);
20789         return ret_ref;
20790 }
20791
20792 uint64_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
20793         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20794         *ret_copy = ClosureReason_cooperative_closure();
20795         uint64_t ret_ref = tag_ptr(ret_copy, true);
20796         return ret_ref;
20797 }
20798
20799 uint64_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
20800         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20801         *ret_copy = ClosureReason_commitment_tx_confirmed();
20802         uint64_t ret_ref = tag_ptr(ret_copy, true);
20803         return ret_ref;
20804 }
20805
20806 uint64_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
20807         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20808         *ret_copy = ClosureReason_funding_timed_out();
20809         uint64_t ret_ref = tag_ptr(ret_copy, true);
20810         return ret_ref;
20811 }
20812
20813 uint64_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
20814         LDKStr err_conv = str_ref_to_owned_c(err);
20815         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20816         *ret_copy = ClosureReason_processing_error(err_conv);
20817         uint64_t ret_ref = tag_ptr(ret_copy, true);
20818         return ret_ref;
20819 }
20820
20821 uint64_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
20822         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20823         *ret_copy = ClosureReason_disconnected_peer();
20824         uint64_t ret_ref = tag_ptr(ret_copy, true);
20825         return ret_ref;
20826 }
20827
20828 uint64_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
20829         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20830         *ret_copy = ClosureReason_outdated_channel_manager();
20831         uint64_t ret_ref = tag_ptr(ret_copy, true);
20832         return ret_ref;
20833 }
20834
20835 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint64_t obj) {
20836         LDKClosureReason* obj_conv = (LDKClosureReason*)untag_ptr(obj);
20837         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
20838         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20839         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20840         CVec_u8Z_free(ret_var);
20841         return ret_arr;
20842 }
20843
20844 uint64_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
20845         LDKu8slice ser_ref;
20846         ser_ref.datalen = ser->arr_len;
20847         ser_ref.data = ser->elems;
20848         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
20849         *ret_conv = ClosureReason_read(ser_ref);
20850         FREE(ser);
20851         return tag_ptr(ret_conv, true);
20852 }
20853
20854 void  __attribute__((export_name("TS_HTLCDestination_free"))) TS_HTLCDestination_free(uint64_t this_ptr) {
20855         if (!ptr_is_owned(this_ptr)) return;
20856         void* this_ptr_ptr = untag_ptr(this_ptr);
20857         CHECK_ACCESS(this_ptr_ptr);
20858         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
20859         FREE(untag_ptr(this_ptr));
20860         HTLCDestination_free(this_ptr_conv);
20861 }
20862
20863 static inline uint64_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
20864         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20865         *ret_copy = HTLCDestination_clone(arg);
20866         uint64_t ret_ref = tag_ptr(ret_copy, true);
20867         return ret_ref;
20868 }
20869 int64_t  __attribute__((export_name("TS_HTLCDestination_clone_ptr"))) TS_HTLCDestination_clone_ptr(uint64_t arg) {
20870         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)untag_ptr(arg);
20871         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
20872         return ret_conv;
20873 }
20874
20875 uint64_t  __attribute__((export_name("TS_HTLCDestination_clone"))) TS_HTLCDestination_clone(uint64_t orig) {
20876         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)untag_ptr(orig);
20877         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20878         *ret_copy = HTLCDestination_clone(orig_conv);
20879         uint64_t ret_ref = tag_ptr(ret_copy, true);
20880         return ret_ref;
20881 }
20882
20883 uint64_t  __attribute__((export_name("TS_HTLCDestination_next_hop_channel"))) TS_HTLCDestination_next_hop_channel(int8_tArray node_id, int8_tArray channel_id) {
20884         LDKPublicKey node_id_ref;
20885         CHECK(node_id->arr_len == 33);
20886         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20887         LDKThirtyTwoBytes channel_id_ref;
20888         CHECK(channel_id->arr_len == 32);
20889         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
20890         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20891         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
20892         uint64_t ret_ref = tag_ptr(ret_copy, true);
20893         return ret_ref;
20894 }
20895
20896 uint64_t  __attribute__((export_name("TS_HTLCDestination_unknown_next_hop"))) TS_HTLCDestination_unknown_next_hop(int64_t requested_forward_scid) {
20897         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20898         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
20899         uint64_t ret_ref = tag_ptr(ret_copy, true);
20900         return ret_ref;
20901 }
20902
20903 uint64_t  __attribute__((export_name("TS_HTLCDestination_failed_payment"))) TS_HTLCDestination_failed_payment(int8_tArray payment_hash) {
20904         LDKThirtyTwoBytes payment_hash_ref;
20905         CHECK(payment_hash->arr_len == 32);
20906         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20907         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20908         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
20909         uint64_t ret_ref = tag_ptr(ret_copy, true);
20910         return ret_ref;
20911 }
20912
20913 int8_tArray  __attribute__((export_name("TS_HTLCDestination_write"))) TS_HTLCDestination_write(uint64_t obj) {
20914         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)untag_ptr(obj);
20915         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
20916         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20917         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20918         CVec_u8Z_free(ret_var);
20919         return ret_arr;
20920 }
20921
20922 uint64_t  __attribute__((export_name("TS_HTLCDestination_read"))) TS_HTLCDestination_read(int8_tArray ser) {
20923         LDKu8slice ser_ref;
20924         ser_ref.datalen = ser->arr_len;
20925         ser_ref.data = ser->elems;
20926         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
20927         *ret_conv = HTLCDestination_read(ser_ref);
20928         FREE(ser);
20929         return tag_ptr(ret_conv, true);
20930 }
20931
20932 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint64_t this_ptr) {
20933         if (!ptr_is_owned(this_ptr)) return;
20934         void* this_ptr_ptr = untag_ptr(this_ptr);
20935         CHECK_ACCESS(this_ptr_ptr);
20936         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
20937         FREE(untag_ptr(this_ptr));
20938         Event_free(this_ptr_conv);
20939 }
20940
20941 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
20942         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20943         *ret_copy = Event_clone(arg);
20944         uint64_t ret_ref = tag_ptr(ret_copy, true);
20945         return ret_ref;
20946 }
20947 int64_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint64_t arg) {
20948         LDKEvent* arg_conv = (LDKEvent*)untag_ptr(arg);
20949         int64_t ret_conv = Event_clone_ptr(arg_conv);
20950         return ret_conv;
20951 }
20952
20953 uint64_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint64_t orig) {
20954         LDKEvent* orig_conv = (LDKEvent*)untag_ptr(orig);
20955         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20956         *ret_copy = Event_clone(orig_conv);
20957         uint64_t ret_ref = tag_ptr(ret_copy, true);
20958         return ret_ref;
20959 }
20960
20961 uint64_t  __attribute__((export_name("TS_Event_funding_generation_ready"))) TS_Event_funding_generation_ready(int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
20962         LDKThirtyTwoBytes temporary_channel_id_ref;
20963         CHECK(temporary_channel_id->arr_len == 32);
20964         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
20965         LDKPublicKey counterparty_node_id_ref;
20966         CHECK(counterparty_node_id->arr_len == 33);
20967         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
20968         LDKCVec_u8Z output_script_ref;
20969         output_script_ref.datalen = output_script->arr_len;
20970         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
20971         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
20972         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20973         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
20974         uint64_t ret_ref = tag_ptr(ret_copy, true);
20975         return ret_ref;
20976 }
20977
20978 uint64_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amount_msat, uint64_t purpose) {
20979         LDKThirtyTwoBytes payment_hash_ref;
20980         CHECK(payment_hash->arr_len == 32);
20981         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20982         void* purpose_ptr = untag_ptr(purpose);
20983         CHECK_ACCESS(purpose_ptr);
20984         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20985         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
20986         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20987         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
20988         uint64_t ret_ref = tag_ptr(ret_copy, true);
20989         return ret_ref;
20990 }
20991
20992 uint64_t  __attribute__((export_name("TS_Event_payment_claimed"))) TS_Event_payment_claimed(int8_tArray payment_hash, int64_t amount_msat, uint64_t purpose) {
20993         LDKThirtyTwoBytes payment_hash_ref;
20994         CHECK(payment_hash->arr_len == 32);
20995         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20996         void* purpose_ptr = untag_ptr(purpose);
20997         CHECK_ACCESS(purpose_ptr);
20998         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20999         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
21000         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21001         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
21002         uint64_t ret_ref = tag_ptr(ret_copy, true);
21003         return ret_ref;
21004 }
21005
21006 uint64_t  __attribute__((export_name("TS_Event_payment_sent"))) TS_Event_payment_sent(int8_tArray payment_id, int8_tArray payment_preimage, int8_tArray payment_hash, uint64_t fee_paid_msat) {
21007         LDKThirtyTwoBytes payment_id_ref;
21008         CHECK(payment_id->arr_len == 32);
21009         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21010         LDKThirtyTwoBytes payment_preimage_ref;
21011         CHECK(payment_preimage->arr_len == 32);
21012         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
21013         LDKThirtyTwoBytes payment_hash_ref;
21014         CHECK(payment_hash->arr_len == 32);
21015         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21016         void* fee_paid_msat_ptr = untag_ptr(fee_paid_msat);
21017         CHECK_ACCESS(fee_paid_msat_ptr);
21018         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
21019         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_paid_msat));
21020         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21021         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
21022         uint64_t ret_ref = tag_ptr(ret_copy, true);
21023         return ret_ref;
21024 }
21025
21026 uint64_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
21027         LDKThirtyTwoBytes payment_id_ref;
21028         CHECK(payment_id->arr_len == 32);
21029         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21030         LDKThirtyTwoBytes payment_hash_ref;
21031         CHECK(payment_hash->arr_len == 32);
21032         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21033         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21034         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
21035         uint64_t ret_ref = tag_ptr(ret_copy, true);
21036         return ret_ref;
21037 }
21038
21039 uint64_t  __attribute__((export_name("TS_Event_payment_path_successful"))) TS_Event_payment_path_successful(int8_tArray payment_id, int8_tArray payment_hash, uint64_tArray path) {
21040         LDKThirtyTwoBytes payment_id_ref;
21041         CHECK(payment_id->arr_len == 32);
21042         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21043         LDKThirtyTwoBytes payment_hash_ref;
21044         CHECK(payment_hash->arr_len == 32);
21045         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21046         LDKCVec_RouteHopZ path_constr;
21047         path_constr.datalen = path->arr_len;
21048         if (path_constr.datalen > 0)
21049                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21050         else
21051                 path_constr.data = NULL;
21052         uint64_t* path_vals = path->elems;
21053         for (size_t k = 0; k < path_constr.datalen; k++) {
21054                 uint64_t path_conv_10 = path_vals[k];
21055                 LDKRouteHop path_conv_10_conv;
21056                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
21057                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
21058                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21059                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21060                 path_constr.data[k] = path_conv_10_conv;
21061         }
21062         FREE(path);
21063         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21064         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
21065         uint64_t ret_ref = tag_ptr(ret_copy, true);
21066         return ret_ref;
21067 }
21068
21069 uint64_t  __attribute__((export_name("TS_Event_payment_path_failed"))) TS_Event_payment_path_failed(int8_tArray payment_id, int8_tArray payment_hash, jboolean payment_failed_permanently, uint64_t network_update, jboolean all_paths_failed, uint64_tArray path, uint64_t short_channel_id, uint64_t retry) {
21070         LDKThirtyTwoBytes payment_id_ref;
21071         CHECK(payment_id->arr_len == 32);
21072         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21073         LDKThirtyTwoBytes payment_hash_ref;
21074         CHECK(payment_hash->arr_len == 32);
21075         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21076         void* network_update_ptr = untag_ptr(network_update);
21077         CHECK_ACCESS(network_update_ptr);
21078         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
21079         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(network_update));
21080         LDKCVec_RouteHopZ path_constr;
21081         path_constr.datalen = path->arr_len;
21082         if (path_constr.datalen > 0)
21083                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21084         else
21085                 path_constr.data = NULL;
21086         uint64_t* path_vals = path->elems;
21087         for (size_t k = 0; k < path_constr.datalen; k++) {
21088                 uint64_t path_conv_10 = path_vals[k];
21089                 LDKRouteHop path_conv_10_conv;
21090                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
21091                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
21092                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21093                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21094                 path_constr.data[k] = path_conv_10_conv;
21095         }
21096         FREE(path);
21097         void* short_channel_id_ptr = untag_ptr(short_channel_id);
21098         CHECK_ACCESS(short_channel_id_ptr);
21099         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
21100         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
21101         LDKRouteParameters retry_conv;
21102         retry_conv.inner = untag_ptr(retry);
21103         retry_conv.is_owned = ptr_is_owned(retry);
21104         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
21105         retry_conv = RouteParameters_clone(&retry_conv);
21106         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21107         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, payment_failed_permanently, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
21108         uint64_t ret_ref = tag_ptr(ret_copy, true);
21109         return ret_ref;
21110 }
21111
21112 uint64_t  __attribute__((export_name("TS_Event_probe_successful"))) TS_Event_probe_successful(int8_tArray payment_id, int8_tArray payment_hash, uint64_tArray path) {
21113         LDKThirtyTwoBytes payment_id_ref;
21114         CHECK(payment_id->arr_len == 32);
21115         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21116         LDKThirtyTwoBytes payment_hash_ref;
21117         CHECK(payment_hash->arr_len == 32);
21118         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21119         LDKCVec_RouteHopZ path_constr;
21120         path_constr.datalen = path->arr_len;
21121         if (path_constr.datalen > 0)
21122                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21123         else
21124                 path_constr.data = NULL;
21125         uint64_t* path_vals = path->elems;
21126         for (size_t k = 0; k < path_constr.datalen; k++) {
21127                 uint64_t path_conv_10 = path_vals[k];
21128                 LDKRouteHop path_conv_10_conv;
21129                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
21130                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
21131                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21132                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21133                 path_constr.data[k] = path_conv_10_conv;
21134         }
21135         FREE(path);
21136         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21137         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_constr);
21138         uint64_t ret_ref = tag_ptr(ret_copy, true);
21139         return ret_ref;
21140 }
21141
21142 uint64_t  __attribute__((export_name("TS_Event_probe_failed"))) TS_Event_probe_failed(int8_tArray payment_id, int8_tArray payment_hash, uint64_tArray path, uint64_t short_channel_id) {
21143         LDKThirtyTwoBytes payment_id_ref;
21144         CHECK(payment_id->arr_len == 32);
21145         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21146         LDKThirtyTwoBytes payment_hash_ref;
21147         CHECK(payment_hash->arr_len == 32);
21148         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21149         LDKCVec_RouteHopZ path_constr;
21150         path_constr.datalen = path->arr_len;
21151         if (path_constr.datalen > 0)
21152                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21153         else
21154                 path_constr.data = NULL;
21155         uint64_t* path_vals = path->elems;
21156         for (size_t k = 0; k < path_constr.datalen; k++) {
21157                 uint64_t path_conv_10 = path_vals[k];
21158                 LDKRouteHop path_conv_10_conv;
21159                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
21160                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
21161                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21162                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21163                 path_constr.data[k] = path_conv_10_conv;
21164         }
21165         FREE(path);
21166         void* short_channel_id_ptr = untag_ptr(short_channel_id);
21167         CHECK_ACCESS(short_channel_id_ptr);
21168         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
21169         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
21170         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21171         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_constr, short_channel_id_conv);
21172         uint64_t ret_ref = tag_ptr(ret_copy, true);
21173         return ret_ref;
21174 }
21175
21176 uint64_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
21177         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21178         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
21179         uint64_t ret_ref = tag_ptr(ret_copy, true);
21180         return ret_ref;
21181 }
21182
21183 uint64_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint64_tArray outputs) {
21184         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
21185         outputs_constr.datalen = outputs->arr_len;
21186         if (outputs_constr.datalen > 0)
21187                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
21188         else
21189                 outputs_constr.data = NULL;
21190         uint64_t* outputs_vals = outputs->elems;
21191         for (size_t b = 0; b < outputs_constr.datalen; b++) {
21192                 uint64_t outputs_conv_27 = outputs_vals[b];
21193                 void* outputs_conv_27_ptr = untag_ptr(outputs_conv_27);
21194                 CHECK_ACCESS(outputs_conv_27_ptr);
21195                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
21196                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(outputs_conv_27));
21197                 outputs_constr.data[b] = outputs_conv_27_conv;
21198         }
21199         FREE(outputs);
21200         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21201         *ret_copy = Event_spendable_outputs(outputs_constr);
21202         uint64_t ret_ref = tag_ptr(ret_copy, true);
21203         return ret_ref;
21204 }
21205
21206 uint64_t  __attribute__((export_name("TS_Event_payment_forwarded"))) TS_Event_payment_forwarded(int8_tArray prev_channel_id, int8_tArray next_channel_id, uint64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
21207         LDKThirtyTwoBytes prev_channel_id_ref;
21208         CHECK(prev_channel_id->arr_len == 32);
21209         memcpy(prev_channel_id_ref.data, prev_channel_id->elems, 32); FREE(prev_channel_id);
21210         LDKThirtyTwoBytes next_channel_id_ref;
21211         CHECK(next_channel_id->arr_len == 32);
21212         memcpy(next_channel_id_ref.data, next_channel_id->elems, 32); FREE(next_channel_id);
21213         void* fee_earned_msat_ptr = untag_ptr(fee_earned_msat);
21214         CHECK_ACCESS(fee_earned_msat_ptr);
21215         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
21216         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_earned_msat));
21217         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21218         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
21219         uint64_t ret_ref = tag_ptr(ret_copy, true);
21220         return ret_ref;
21221 }
21222
21223 uint64_t  __attribute__((export_name("TS_Event_channel_closed"))) TS_Event_channel_closed(int8_tArray channel_id, int64_t user_channel_id, uint64_t reason) {
21224         LDKThirtyTwoBytes channel_id_ref;
21225         CHECK(channel_id->arr_len == 32);
21226         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
21227         void* reason_ptr = untag_ptr(reason);
21228         CHECK_ACCESS(reason_ptr);
21229         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
21230         reason_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(reason));
21231         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21232         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
21233         uint64_t ret_ref = tag_ptr(ret_copy, true);
21234         return ret_ref;
21235 }
21236
21237 uint64_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
21238         LDKThirtyTwoBytes channel_id_ref;
21239         CHECK(channel_id->arr_len == 32);
21240         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
21241         LDKTransaction transaction_ref;
21242         transaction_ref.datalen = transaction->arr_len;
21243         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
21244         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
21245         transaction_ref.data_is_owned = true;
21246         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21247         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
21248         uint64_t ret_ref = tag_ptr(ret_copy, true);
21249         return ret_ref;
21250 }
21251
21252 uint64_t  __attribute__((export_name("TS_Event_open_channel_request"))) TS_Event_open_channel_request(int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t funding_satoshis, int64_t push_msat, uint64_t channel_type) {
21253         LDKThirtyTwoBytes temporary_channel_id_ref;
21254         CHECK(temporary_channel_id->arr_len == 32);
21255         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
21256         LDKPublicKey counterparty_node_id_ref;
21257         CHECK(counterparty_node_id->arr_len == 33);
21258         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
21259         LDKChannelTypeFeatures channel_type_conv;
21260         channel_type_conv.inner = untag_ptr(channel_type);
21261         channel_type_conv.is_owned = ptr_is_owned(channel_type);
21262         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
21263         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
21264         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21265         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
21266         uint64_t ret_ref = tag_ptr(ret_copy, true);
21267         return ret_ref;
21268 }
21269
21270 uint64_t  __attribute__((export_name("TS_Event_htlchandling_failed"))) TS_Event_htlchandling_failed(int8_tArray prev_channel_id, uint64_t failed_next_destination) {
21271         LDKThirtyTwoBytes prev_channel_id_ref;
21272         CHECK(prev_channel_id->arr_len == 32);
21273         memcpy(prev_channel_id_ref.data, prev_channel_id->elems, 32); FREE(prev_channel_id);
21274         void* failed_next_destination_ptr = untag_ptr(failed_next_destination);
21275         CHECK_ACCESS(failed_next_destination_ptr);
21276         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
21277         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(failed_next_destination));
21278         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21279         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
21280         uint64_t ret_ref = tag_ptr(ret_copy, true);
21281         return ret_ref;
21282 }
21283
21284 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint64_t obj) {
21285         LDKEvent* obj_conv = (LDKEvent*)untag_ptr(obj);
21286         LDKCVec_u8Z ret_var = Event_write(obj_conv);
21287         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21288         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21289         CVec_u8Z_free(ret_var);
21290         return ret_arr;
21291 }
21292
21293 uint64_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
21294         LDKu8slice ser_ref;
21295         ser_ref.datalen = ser->arr_len;
21296         ser_ref.data = ser->elems;
21297         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
21298         *ret_conv = Event_read(ser_ref);
21299         FREE(ser);
21300         return tag_ptr(ret_conv, true);
21301 }
21302
21303 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint64_t this_ptr) {
21304         if (!ptr_is_owned(this_ptr)) return;
21305         void* this_ptr_ptr = untag_ptr(this_ptr);
21306         CHECK_ACCESS(this_ptr_ptr);
21307         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
21308         FREE(untag_ptr(this_ptr));
21309         MessageSendEvent_free(this_ptr_conv);
21310 }
21311
21312 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
21313         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21314         *ret_copy = MessageSendEvent_clone(arg);
21315         uint64_t ret_ref = tag_ptr(ret_copy, true);
21316         return ret_ref;
21317 }
21318 int64_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint64_t arg) {
21319         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)untag_ptr(arg);
21320         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
21321         return ret_conv;
21322 }
21323
21324 uint64_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint64_t orig) {
21325         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)untag_ptr(orig);
21326         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21327         *ret_copy = MessageSendEvent_clone(orig_conv);
21328         uint64_t ret_ref = tag_ptr(ret_copy, true);
21329         return ret_ref;
21330 }
21331
21332 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint64_t msg) {
21333         LDKPublicKey node_id_ref;
21334         CHECK(node_id->arr_len == 33);
21335         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21336         LDKAcceptChannel msg_conv;
21337         msg_conv.inner = untag_ptr(msg);
21338         msg_conv.is_owned = ptr_is_owned(msg);
21339         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21340         msg_conv = AcceptChannel_clone(&msg_conv);
21341         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21342         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
21343         uint64_t ret_ref = tag_ptr(ret_copy, true);
21344         return ret_ref;
21345 }
21346
21347 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint64_t msg) {
21348         LDKPublicKey node_id_ref;
21349         CHECK(node_id->arr_len == 33);
21350         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21351         LDKOpenChannel msg_conv;
21352         msg_conv.inner = untag_ptr(msg);
21353         msg_conv.is_owned = ptr_is_owned(msg);
21354         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21355         msg_conv = OpenChannel_clone(&msg_conv);
21356         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21357         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
21358         uint64_t ret_ref = tag_ptr(ret_copy, true);
21359         return ret_ref;
21360 }
21361
21362 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint64_t msg) {
21363         LDKPublicKey node_id_ref;
21364         CHECK(node_id->arr_len == 33);
21365         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21366         LDKFundingCreated msg_conv;
21367         msg_conv.inner = untag_ptr(msg);
21368         msg_conv.is_owned = ptr_is_owned(msg);
21369         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21370         msg_conv = FundingCreated_clone(&msg_conv);
21371         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21372         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
21373         uint64_t ret_ref = tag_ptr(ret_copy, true);
21374         return ret_ref;
21375 }
21376
21377 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint64_t msg) {
21378         LDKPublicKey node_id_ref;
21379         CHECK(node_id->arr_len == 33);
21380         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21381         LDKFundingSigned msg_conv;
21382         msg_conv.inner = untag_ptr(msg);
21383         msg_conv.is_owned = ptr_is_owned(msg);
21384         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21385         msg_conv = FundingSigned_clone(&msg_conv);
21386         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21387         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
21388         uint64_t ret_ref = tag_ptr(ret_copy, true);
21389         return ret_ref;
21390 }
21391
21392 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_ready"))) TS_MessageSendEvent_send_channel_ready(int8_tArray node_id, uint64_t msg) {
21393         LDKPublicKey node_id_ref;
21394         CHECK(node_id->arr_len == 33);
21395         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21396         LDKChannelReady msg_conv;
21397         msg_conv.inner = untag_ptr(msg);
21398         msg_conv.is_owned = ptr_is_owned(msg);
21399         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21400         msg_conv = ChannelReady_clone(&msg_conv);
21401         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21402         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
21403         uint64_t ret_ref = tag_ptr(ret_copy, true);
21404         return ret_ref;
21405 }
21406
21407 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint64_t msg) {
21408         LDKPublicKey node_id_ref;
21409         CHECK(node_id->arr_len == 33);
21410         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21411         LDKAnnouncementSignatures msg_conv;
21412         msg_conv.inner = untag_ptr(msg);
21413         msg_conv.is_owned = ptr_is_owned(msg);
21414         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21415         msg_conv = AnnouncementSignatures_clone(&msg_conv);
21416         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21417         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
21418         uint64_t ret_ref = tag_ptr(ret_copy, true);
21419         return ret_ref;
21420 }
21421
21422 uint64_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint64_t updates) {
21423         LDKPublicKey node_id_ref;
21424         CHECK(node_id->arr_len == 33);
21425         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21426         LDKCommitmentUpdate updates_conv;
21427         updates_conv.inner = untag_ptr(updates);
21428         updates_conv.is_owned = ptr_is_owned(updates);
21429         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
21430         updates_conv = CommitmentUpdate_clone(&updates_conv);
21431         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21432         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
21433         uint64_t ret_ref = tag_ptr(ret_copy, true);
21434         return ret_ref;
21435 }
21436
21437 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint64_t msg) {
21438         LDKPublicKey node_id_ref;
21439         CHECK(node_id->arr_len == 33);
21440         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21441         LDKRevokeAndACK msg_conv;
21442         msg_conv.inner = untag_ptr(msg);
21443         msg_conv.is_owned = ptr_is_owned(msg);
21444         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21445         msg_conv = RevokeAndACK_clone(&msg_conv);
21446         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21447         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
21448         uint64_t ret_ref = tag_ptr(ret_copy, true);
21449         return ret_ref;
21450 }
21451
21452 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint64_t msg) {
21453         LDKPublicKey node_id_ref;
21454         CHECK(node_id->arr_len == 33);
21455         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21456         LDKClosingSigned msg_conv;
21457         msg_conv.inner = untag_ptr(msg);
21458         msg_conv.is_owned = ptr_is_owned(msg);
21459         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21460         msg_conv = ClosingSigned_clone(&msg_conv);
21461         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21462         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
21463         uint64_t ret_ref = tag_ptr(ret_copy, true);
21464         return ret_ref;
21465 }
21466
21467 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint64_t msg) {
21468         LDKPublicKey node_id_ref;
21469         CHECK(node_id->arr_len == 33);
21470         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21471         LDKShutdown msg_conv;
21472         msg_conv.inner = untag_ptr(msg);
21473         msg_conv.is_owned = ptr_is_owned(msg);
21474         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21475         msg_conv = Shutdown_clone(&msg_conv);
21476         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21477         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
21478         uint64_t ret_ref = tag_ptr(ret_copy, true);
21479         return ret_ref;
21480 }
21481
21482 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint64_t msg) {
21483         LDKPublicKey node_id_ref;
21484         CHECK(node_id->arr_len == 33);
21485         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21486         LDKChannelReestablish msg_conv;
21487         msg_conv.inner = untag_ptr(msg);
21488         msg_conv.is_owned = ptr_is_owned(msg);
21489         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21490         msg_conv = ChannelReestablish_clone(&msg_conv);
21491         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21492         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
21493         uint64_t ret_ref = tag_ptr(ret_copy, true);
21494         return ret_ref;
21495 }
21496
21497 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_announcement"))) TS_MessageSendEvent_send_channel_announcement(int8_tArray node_id, uint64_t msg, uint64_t update_msg) {
21498         LDKPublicKey node_id_ref;
21499         CHECK(node_id->arr_len == 33);
21500         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21501         LDKChannelAnnouncement msg_conv;
21502         msg_conv.inner = untag_ptr(msg);
21503         msg_conv.is_owned = ptr_is_owned(msg);
21504         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21505         msg_conv = ChannelAnnouncement_clone(&msg_conv);
21506         LDKChannelUpdate update_msg_conv;
21507         update_msg_conv.inner = untag_ptr(update_msg);
21508         update_msg_conv.is_owned = ptr_is_owned(update_msg);
21509         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
21510         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
21511         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21512         *ret_copy = MessageSendEvent_send_channel_announcement(node_id_ref, msg_conv, update_msg_conv);
21513         uint64_t ret_ref = tag_ptr(ret_copy, true);
21514         return ret_ref;
21515 }
21516
21517 uint64_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint64_t msg, uint64_t update_msg) {
21518         LDKChannelAnnouncement msg_conv;
21519         msg_conv.inner = untag_ptr(msg);
21520         msg_conv.is_owned = ptr_is_owned(msg);
21521         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21522         msg_conv = ChannelAnnouncement_clone(&msg_conv);
21523         LDKChannelUpdate update_msg_conv;
21524         update_msg_conv.inner = untag_ptr(update_msg);
21525         update_msg_conv.is_owned = ptr_is_owned(update_msg);
21526         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
21527         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
21528         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21529         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
21530         uint64_t ret_ref = tag_ptr(ret_copy, true);
21531         return ret_ref;
21532 }
21533
21534 uint64_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint64_t msg) {
21535         LDKChannelUpdate msg_conv;
21536         msg_conv.inner = untag_ptr(msg);
21537         msg_conv.is_owned = ptr_is_owned(msg);
21538         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21539         msg_conv = ChannelUpdate_clone(&msg_conv);
21540         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21541         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
21542         uint64_t ret_ref = tag_ptr(ret_copy, true);
21543         return ret_ref;
21544 }
21545
21546 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint64_t msg) {
21547         LDKPublicKey node_id_ref;
21548         CHECK(node_id->arr_len == 33);
21549         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21550         LDKChannelUpdate msg_conv;
21551         msg_conv.inner = untag_ptr(msg);
21552         msg_conv.is_owned = ptr_is_owned(msg);
21553         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21554         msg_conv = ChannelUpdate_clone(&msg_conv);
21555         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21556         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
21557         uint64_t ret_ref = tag_ptr(ret_copy, true);
21558         return ret_ref;
21559 }
21560
21561 uint64_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint64_t action) {
21562         LDKPublicKey node_id_ref;
21563         CHECK(node_id->arr_len == 33);
21564         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21565         void* action_ptr = untag_ptr(action);
21566         CHECK_ACCESS(action_ptr);
21567         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
21568         action_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action));
21569         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21570         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
21571         uint64_t ret_ref = tag_ptr(ret_copy, true);
21572         return ret_ref;
21573 }
21574
21575 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint64_t msg) {
21576         LDKPublicKey node_id_ref;
21577         CHECK(node_id->arr_len == 33);
21578         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21579         LDKQueryChannelRange msg_conv;
21580         msg_conv.inner = untag_ptr(msg);
21581         msg_conv.is_owned = ptr_is_owned(msg);
21582         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21583         msg_conv = QueryChannelRange_clone(&msg_conv);
21584         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21585         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
21586         uint64_t ret_ref = tag_ptr(ret_copy, true);
21587         return ret_ref;
21588 }
21589
21590 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint64_t msg) {
21591         LDKPublicKey node_id_ref;
21592         CHECK(node_id->arr_len == 33);
21593         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21594         LDKQueryShortChannelIds msg_conv;
21595         msg_conv.inner = untag_ptr(msg);
21596         msg_conv.is_owned = ptr_is_owned(msg);
21597         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21598         msg_conv = QueryShortChannelIds_clone(&msg_conv);
21599         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21600         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
21601         uint64_t ret_ref = tag_ptr(ret_copy, true);
21602         return ret_ref;
21603 }
21604
21605 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint64_t msg) {
21606         LDKPublicKey node_id_ref;
21607         CHECK(node_id->arr_len == 33);
21608         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21609         LDKReplyChannelRange msg_conv;
21610         msg_conv.inner = untag_ptr(msg);
21611         msg_conv.is_owned = ptr_is_owned(msg);
21612         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21613         msg_conv = ReplyChannelRange_clone(&msg_conv);
21614         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21615         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
21616         uint64_t ret_ref = tag_ptr(ret_copy, true);
21617         return ret_ref;
21618 }
21619
21620 uint64_t  __attribute__((export_name("TS_MessageSendEvent_send_gossip_timestamp_filter"))) TS_MessageSendEvent_send_gossip_timestamp_filter(int8_tArray node_id, uint64_t msg) {
21621         LDKPublicKey node_id_ref;
21622         CHECK(node_id->arr_len == 33);
21623         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21624         LDKGossipTimestampFilter msg_conv;
21625         msg_conv.inner = untag_ptr(msg);
21626         msg_conv.is_owned = ptr_is_owned(msg);
21627         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21628         msg_conv = GossipTimestampFilter_clone(&msg_conv);
21629         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21630         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
21631         uint64_t ret_ref = tag_ptr(ret_copy, true);
21632         return ret_ref;
21633 }
21634
21635 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint64_t this_ptr) {
21636         if (!ptr_is_owned(this_ptr)) return;
21637         void* this_ptr_ptr = untag_ptr(this_ptr);
21638         CHECK_ACCESS(this_ptr_ptr);
21639         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
21640         FREE(untag_ptr(this_ptr));
21641         MessageSendEventsProvider_free(this_ptr_conv);
21642 }
21643
21644 void  __attribute__((export_name("TS_OnionMessageProvider_free"))) TS_OnionMessageProvider_free(uint64_t this_ptr) {
21645         if (!ptr_is_owned(this_ptr)) return;
21646         void* this_ptr_ptr = untag_ptr(this_ptr);
21647         CHECK_ACCESS(this_ptr_ptr);
21648         LDKOnionMessageProvider this_ptr_conv = *(LDKOnionMessageProvider*)(this_ptr_ptr);
21649         FREE(untag_ptr(this_ptr));
21650         OnionMessageProvider_free(this_ptr_conv);
21651 }
21652
21653 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint64_t this_ptr) {
21654         if (!ptr_is_owned(this_ptr)) return;
21655         void* this_ptr_ptr = untag_ptr(this_ptr);
21656         CHECK_ACCESS(this_ptr_ptr);
21657         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
21658         FREE(untag_ptr(this_ptr));
21659         EventsProvider_free(this_ptr_conv);
21660 }
21661
21662 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint64_t this_ptr) {
21663         if (!ptr_is_owned(this_ptr)) return;
21664         void* this_ptr_ptr = untag_ptr(this_ptr);
21665         CHECK_ACCESS(this_ptr_ptr);
21666         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
21667         FREE(untag_ptr(this_ptr));
21668         EventHandler_free(this_ptr_conv);
21669 }
21670
21671 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint64_t this_ptr) {
21672         if (!ptr_is_owned(this_ptr)) return;
21673         void* this_ptr_ptr = untag_ptr(this_ptr);
21674         CHECK_ACCESS(this_ptr_ptr);
21675         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
21676         FREE(untag_ptr(this_ptr));
21677         APIError_free(this_ptr_conv);
21678 }
21679
21680 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
21681         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21682         *ret_copy = APIError_clone(arg);
21683         uint64_t ret_ref = tag_ptr(ret_copy, true);
21684         return ret_ref;
21685 }
21686 int64_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint64_t arg) {
21687         LDKAPIError* arg_conv = (LDKAPIError*)untag_ptr(arg);
21688         int64_t ret_conv = APIError_clone_ptr(arg_conv);
21689         return ret_conv;
21690 }
21691
21692 uint64_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint64_t orig) {
21693         LDKAPIError* orig_conv = (LDKAPIError*)untag_ptr(orig);
21694         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21695         *ret_copy = APIError_clone(orig_conv);
21696         uint64_t ret_ref = tag_ptr(ret_copy, true);
21697         return ret_ref;
21698 }
21699
21700 uint64_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
21701         LDKStr err_conv = str_ref_to_owned_c(err);
21702         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21703         *ret_copy = APIError_apimisuse_error(err_conv);
21704         uint64_t ret_ref = tag_ptr(ret_copy, true);
21705         return ret_ref;
21706 }
21707
21708 uint64_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
21709         LDKStr err_conv = str_ref_to_owned_c(err);
21710         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21711         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
21712         uint64_t ret_ref = tag_ptr(ret_copy, true);
21713         return ret_ref;
21714 }
21715
21716 uint64_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
21717         LDKStr err_conv = str_ref_to_owned_c(err);
21718         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21719         *ret_copy = APIError_route_error(err_conv);
21720         uint64_t ret_ref = tag_ptr(ret_copy, true);
21721         return ret_ref;
21722 }
21723
21724 uint64_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
21725         LDKStr err_conv = str_ref_to_owned_c(err);
21726         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21727         *ret_copy = APIError_channel_unavailable(err_conv);
21728         uint64_t ret_ref = tag_ptr(ret_copy, true);
21729         return ret_ref;
21730 }
21731
21732 uint64_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
21733         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21734         *ret_copy = APIError_monitor_update_failed();
21735         uint64_t ret_ref = tag_ptr(ret_copy, true);
21736         return ret_ref;
21737 }
21738
21739 uint64_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint64_t script) {
21740         LDKShutdownScript script_conv;
21741         script_conv.inner = untag_ptr(script);
21742         script_conv.is_owned = ptr_is_owned(script);
21743         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
21744         script_conv = ShutdownScript_clone(&script_conv);
21745         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21746         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
21747         uint64_t ret_ref = tag_ptr(ret_copy, true);
21748         return ret_ref;
21749 }
21750
21751 void  __attribute__((export_name("TS_BigSize_free"))) TS_BigSize_free(uint64_t this_obj) {
21752         LDKBigSize this_obj_conv;
21753         this_obj_conv.inner = untag_ptr(this_obj);
21754         this_obj_conv.is_owned = ptr_is_owned(this_obj);
21755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21756         BigSize_free(this_obj_conv);
21757 }
21758
21759 int64_t  __attribute__((export_name("TS_BigSize_get_a"))) TS_BigSize_get_a(uint64_t this_ptr) {
21760         LDKBigSize this_ptr_conv;
21761         this_ptr_conv.inner = untag_ptr(this_ptr);
21762         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
21763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21764         this_ptr_conv.is_owned = false;
21765         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
21766         return ret_conv;
21767 }
21768
21769 void  __attribute__((export_name("TS_BigSize_set_a"))) TS_BigSize_set_a(uint64_t this_ptr, int64_t val) {
21770         LDKBigSize this_ptr_conv;
21771         this_ptr_conv.inner = untag_ptr(this_ptr);
21772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
21773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21774         this_ptr_conv.is_owned = false;
21775         BigSize_set_a(&this_ptr_conv, val);
21776 }
21777
21778 uint64_t  __attribute__((export_name("TS_BigSize_new"))) TS_BigSize_new(int64_t a_arg) {
21779         LDKBigSize ret_var = BigSize_new(a_arg);
21780         uint64_t ret_ref = 0;
21781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21782         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
21783         return ret_ref;
21784 }
21785
21786 void  __attribute__((export_name("TS_Hostname_free"))) TS_Hostname_free(uint64_t this_obj) {
21787         LDKHostname this_obj_conv;
21788         this_obj_conv.inner = untag_ptr(this_obj);
21789         this_obj_conv.is_owned = ptr_is_owned(this_obj);
21790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21791         Hostname_free(this_obj_conv);
21792 }
21793
21794 static inline uint64_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
21795         LDKHostname ret_var = Hostname_clone(arg);
21796         uint64_t ret_ref = 0;
21797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21798         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
21799         return ret_ref;
21800 }
21801 int64_t  __attribute__((export_name("TS_Hostname_clone_ptr"))) TS_Hostname_clone_ptr(uint64_t arg) {
21802         LDKHostname arg_conv;
21803         arg_conv.inner = untag_ptr(arg);
21804         arg_conv.is_owned = ptr_is_owned(arg);
21805         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21806         arg_conv.is_owned = false;
21807         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
21808         return ret_conv;
21809 }
21810
21811 uint64_t  __attribute__((export_name("TS_Hostname_clone"))) TS_Hostname_clone(uint64_t orig) {
21812         LDKHostname orig_conv;
21813         orig_conv.inner = untag_ptr(orig);
21814         orig_conv.is_owned = ptr_is_owned(orig);
21815         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21816         orig_conv.is_owned = false;
21817         LDKHostname ret_var = Hostname_clone(&orig_conv);
21818         uint64_t ret_ref = 0;
21819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21820         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
21821         return ret_ref;
21822 }
21823
21824 int8_t  __attribute__((export_name("TS_Hostname_len"))) TS_Hostname_len(uint64_t this_arg) {
21825         LDKHostname this_arg_conv;
21826         this_arg_conv.inner = untag_ptr(this_arg);
21827         this_arg_conv.is_owned = ptr_is_owned(this_arg);
21828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21829         this_arg_conv.is_owned = false;
21830         int8_t ret_conv = Hostname_len(&this_arg_conv);
21831         return ret_conv;
21832 }
21833
21834 uint64_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
21835         LDKu8slice msg_ref;
21836         msg_ref.datalen = msg->arr_len;
21837         msg_ref.data = msg->elems;
21838         unsigned char sk_arr[32];
21839         CHECK(sk->arr_len == 32);
21840         memcpy(sk_arr, sk->elems, 32); FREE(sk);
21841         unsigned char (*sk_ref)[32] = &sk_arr;
21842         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21843         *ret_conv = sign(msg_ref, sk_ref);
21844         FREE(msg);
21845         return tag_ptr(ret_conv, true);
21846 }
21847
21848 uint64_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
21849         LDKu8slice msg_ref;
21850         msg_ref.datalen = msg->arr_len;
21851         msg_ref.data = msg->elems;
21852         LDKStr sig_conv = str_ref_to_owned_c(sig);
21853         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21854         *ret_conv = recover_pk(msg_ref, sig_conv);
21855         FREE(msg);
21856         return tag_ptr(ret_conv, true);
21857 }
21858
21859 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
21860         LDKu8slice msg_ref;
21861         msg_ref.datalen = msg->arr_len;
21862         msg_ref.data = msg->elems;
21863         LDKStr sig_conv = str_ref_to_owned_c(sig);
21864         LDKPublicKey pk_ref;
21865         CHECK(pk->arr_len == 33);
21866         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
21867         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
21868         FREE(msg);
21869         return ret_conv;
21870 }
21871
21872 int8_tArray  __attribute__((export_name("TS_construct_invoice_preimage"))) TS_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
21873         LDKu8slice hrp_bytes_ref;
21874         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
21875         hrp_bytes_ref.data = hrp_bytes->elems;
21876         LDKCVec_u5Z data_without_signature_constr;
21877         data_without_signature_constr.datalen = data_without_signature->arr_len;
21878         if (data_without_signature_constr.datalen > 0)
21879                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
21880         else
21881                 data_without_signature_constr.data = NULL;
21882         int8_t* data_without_signature_vals = (void*) data_without_signature->elems;
21883         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
21884                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
21885                 
21886                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
21887         }
21888         FREE(data_without_signature);
21889         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
21890         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21891         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21892         CVec_u8Z_free(ret_var);
21893         FREE(hrp_bytes);
21894         return ret_arr;
21895 }
21896
21897 void  __attribute__((export_name("TS_Persister_free"))) TS_Persister_free(uint64_t this_ptr) {
21898         if (!ptr_is_owned(this_ptr)) return;
21899         void* this_ptr_ptr = untag_ptr(this_ptr);
21900         CHECK_ACCESS(this_ptr_ptr);
21901         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
21902         FREE(untag_ptr(this_ptr));
21903         Persister_free(this_ptr_conv);
21904 }
21905
21906 void  __attribute__((export_name("TS_FutureCallback_free"))) TS_FutureCallback_free(uint64_t this_ptr) {
21907         if (!ptr_is_owned(this_ptr)) return;
21908         void* this_ptr_ptr = untag_ptr(this_ptr);
21909         CHECK_ACCESS(this_ptr_ptr);
21910         LDKFutureCallback this_ptr_conv = *(LDKFutureCallback*)(this_ptr_ptr);
21911         FREE(untag_ptr(this_ptr));
21912         FutureCallback_free(this_ptr_conv);
21913 }
21914
21915 void  __attribute__((export_name("TS_Future_free"))) TS_Future_free(uint64_t this_obj) {
21916         LDKFuture this_obj_conv;
21917         this_obj_conv.inner = untag_ptr(this_obj);
21918         this_obj_conv.is_owned = ptr_is_owned(this_obj);
21919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21920         Future_free(this_obj_conv);
21921 }
21922
21923 void  __attribute__((export_name("TS_Future_register_callback_fn"))) TS_Future_register_callback_fn(uint64_t this_arg, uint64_t callback) {
21924         LDKFuture this_arg_conv;
21925         this_arg_conv.inner = untag_ptr(this_arg);
21926         this_arg_conv.is_owned = ptr_is_owned(this_arg);
21927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21928         this_arg_conv.is_owned = false;
21929         void* callback_ptr = untag_ptr(callback);
21930         CHECK_ACCESS(callback_ptr);
21931         LDKFutureCallback callback_conv = *(LDKFutureCallback*)(callback_ptr);
21932         if (callback_conv.free == LDKFutureCallback_JCalls_free) {
21933                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21934                 LDKFutureCallback_JCalls_cloned(&callback_conv);
21935         }
21936         Future_register_callback_fn(&this_arg_conv, callback_conv);
21937 }
21938
21939 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint64_t orig) {
21940         LDKLevel* orig_conv = (LDKLevel*)untag_ptr(orig);
21941         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
21942         return ret_conv;
21943 }
21944
21945 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
21946         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
21947         return ret_conv;
21948 }
21949
21950 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
21951         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
21952         return ret_conv;
21953 }
21954
21955 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
21956         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
21957         return ret_conv;
21958 }
21959
21960 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
21961         uint32_t ret_conv = LDKLevel_to_js(Level_info());
21962         return ret_conv;
21963 }
21964
21965 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
21966         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
21967         return ret_conv;
21968 }
21969
21970 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
21971         uint32_t ret_conv = LDKLevel_to_js(Level_error());
21972         return ret_conv;
21973 }
21974
21975 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint64_t a, uint64_t b) {
21976         LDKLevel* a_conv = (LDKLevel*)untag_ptr(a);
21977         LDKLevel* b_conv = (LDKLevel*)untag_ptr(b);
21978         jboolean ret_conv = Level_eq(a_conv, b_conv);
21979         return ret_conv;
21980 }
21981
21982 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint64_t o) {
21983         LDKLevel* o_conv = (LDKLevel*)untag_ptr(o);
21984         int64_t ret_conv = Level_hash(o_conv);
21985         return ret_conv;
21986 }
21987
21988 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
21989         uint32_t ret_conv = LDKLevel_to_js(Level_max());
21990         return ret_conv;
21991 }
21992
21993 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint64_t this_obj) {
21994         LDKRecord this_obj_conv;
21995         this_obj_conv.inner = untag_ptr(this_obj);
21996         this_obj_conv.is_owned = ptr_is_owned(this_obj);
21997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21998         Record_free(this_obj_conv);
21999 }
22000
22001 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint64_t this_ptr) {
22002         LDKRecord this_ptr_conv;
22003         this_ptr_conv.inner = untag_ptr(this_ptr);
22004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22006         this_ptr_conv.is_owned = false;
22007         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
22008         return ret_conv;
22009 }
22010
22011 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint64_t this_ptr, uint32_t val) {
22012         LDKRecord this_ptr_conv;
22013         this_ptr_conv.inner = untag_ptr(this_ptr);
22014         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22016         this_ptr_conv.is_owned = false;
22017         LDKLevel val_conv = LDKLevel_from_js(val);
22018         Record_set_level(&this_ptr_conv, val_conv);
22019 }
22020
22021 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint64_t this_ptr) {
22022         LDKRecord this_ptr_conv;
22023         this_ptr_conv.inner = untag_ptr(this_ptr);
22024         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22026         this_ptr_conv.is_owned = false;
22027         LDKStr ret_str = Record_get_args(&this_ptr_conv);
22028         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22029         Str_free(ret_str);
22030         return ret_conv;
22031 }
22032
22033 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint64_t this_ptr, jstring val) {
22034         LDKRecord this_ptr_conv;
22035         this_ptr_conv.inner = untag_ptr(this_ptr);
22036         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22038         this_ptr_conv.is_owned = false;
22039         LDKStr val_conv = str_ref_to_owned_c(val);
22040         Record_set_args(&this_ptr_conv, val_conv);
22041 }
22042
22043 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint64_t this_ptr) {
22044         LDKRecord this_ptr_conv;
22045         this_ptr_conv.inner = untag_ptr(this_ptr);
22046         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22048         this_ptr_conv.is_owned = false;
22049         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
22050         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22051         Str_free(ret_str);
22052         return ret_conv;
22053 }
22054
22055 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint64_t this_ptr, jstring val) {
22056         LDKRecord this_ptr_conv;
22057         this_ptr_conv.inner = untag_ptr(this_ptr);
22058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22060         this_ptr_conv.is_owned = false;
22061         LDKStr val_conv = str_ref_to_owned_c(val);
22062         Record_set_module_path(&this_ptr_conv, val_conv);
22063 }
22064
22065 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint64_t this_ptr) {
22066         LDKRecord this_ptr_conv;
22067         this_ptr_conv.inner = untag_ptr(this_ptr);
22068         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22070         this_ptr_conv.is_owned = false;
22071         LDKStr ret_str = Record_get_file(&this_ptr_conv);
22072         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22073         Str_free(ret_str);
22074         return ret_conv;
22075 }
22076
22077 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint64_t this_ptr, jstring val) {
22078         LDKRecord this_ptr_conv;
22079         this_ptr_conv.inner = untag_ptr(this_ptr);
22080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22082         this_ptr_conv.is_owned = false;
22083         LDKStr val_conv = str_ref_to_owned_c(val);
22084         Record_set_file(&this_ptr_conv, val_conv);
22085 }
22086
22087 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint64_t this_ptr) {
22088         LDKRecord this_ptr_conv;
22089         this_ptr_conv.inner = untag_ptr(this_ptr);
22090         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22092         this_ptr_conv.is_owned = false;
22093         int32_t ret_conv = Record_get_line(&this_ptr_conv);
22094         return ret_conv;
22095 }
22096
22097 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint64_t this_ptr, int32_t val) {
22098         LDKRecord this_ptr_conv;
22099         this_ptr_conv.inner = untag_ptr(this_ptr);
22100         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22102         this_ptr_conv.is_owned = false;
22103         Record_set_line(&this_ptr_conv, val);
22104 }
22105
22106 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
22107         LDKRecord ret_var = Record_clone(arg);
22108         uint64_t ret_ref = 0;
22109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22110         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22111         return ret_ref;
22112 }
22113 int64_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint64_t arg) {
22114         LDKRecord arg_conv;
22115         arg_conv.inner = untag_ptr(arg);
22116         arg_conv.is_owned = ptr_is_owned(arg);
22117         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22118         arg_conv.is_owned = false;
22119         int64_t ret_conv = Record_clone_ptr(&arg_conv);
22120         return ret_conv;
22121 }
22122
22123 uint64_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint64_t orig) {
22124         LDKRecord orig_conv;
22125         orig_conv.inner = untag_ptr(orig);
22126         orig_conv.is_owned = ptr_is_owned(orig);
22127         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22128         orig_conv.is_owned = false;
22129         LDKRecord ret_var = Record_clone(&orig_conv);
22130         uint64_t ret_ref = 0;
22131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22132         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22133         return ret_ref;
22134 }
22135
22136 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint64_t this_ptr) {
22137         if (!ptr_is_owned(this_ptr)) return;
22138         void* this_ptr_ptr = untag_ptr(this_ptr);
22139         CHECK_ACCESS(this_ptr_ptr);
22140         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
22141         FREE(untag_ptr(this_ptr));
22142         Logger_free(this_ptr_conv);
22143 }
22144
22145 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint64_t this_obj) {
22146         LDKChannelHandshakeConfig this_obj_conv;
22147         this_obj_conv.inner = untag_ptr(this_obj);
22148         this_obj_conv.is_owned = ptr_is_owned(this_obj);
22149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22150         ChannelHandshakeConfig_free(this_obj_conv);
22151 }
22152
22153 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint64_t this_ptr) {
22154         LDKChannelHandshakeConfig this_ptr_conv;
22155         this_ptr_conv.inner = untag_ptr(this_ptr);
22156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22158         this_ptr_conv.is_owned = false;
22159         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
22160         return ret_conv;
22161 }
22162
22163 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint64_t this_ptr, int32_t val) {
22164         LDKChannelHandshakeConfig this_ptr_conv;
22165         this_ptr_conv.inner = untag_ptr(this_ptr);
22166         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22168         this_ptr_conv.is_owned = false;
22169         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
22170 }
22171
22172 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint64_t this_ptr) {
22173         LDKChannelHandshakeConfig this_ptr_conv;
22174         this_ptr_conv.inner = untag_ptr(this_ptr);
22175         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22177         this_ptr_conv.is_owned = false;
22178         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
22179         return ret_conv;
22180 }
22181
22182 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_our_to_self_delay"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint64_t this_ptr, int16_t val) {
22183         LDKChannelHandshakeConfig this_ptr_conv;
22184         this_ptr_conv.inner = untag_ptr(this_ptr);
22185         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22187         this_ptr_conv.is_owned = false;
22188         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
22189 }
22190
22191 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint64_t this_ptr) {
22192         LDKChannelHandshakeConfig this_ptr_conv;
22193         this_ptr_conv.inner = untag_ptr(this_ptr);
22194         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22196         this_ptr_conv.is_owned = false;
22197         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
22198         return ret_conv;
22199 }
22200
22201 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint64_t this_ptr, int64_t val) {
22202         LDKChannelHandshakeConfig this_ptr_conv;
22203         this_ptr_conv.inner = untag_ptr(this_ptr);
22204         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22206         this_ptr_conv.is_owned = false;
22207         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
22208 }
22209
22210 int8_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel"))) TS_ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(uint64_t this_ptr) {
22211         LDKChannelHandshakeConfig this_ptr_conv;
22212         this_ptr_conv.inner = untag_ptr(this_ptr);
22213         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22215         this_ptr_conv.is_owned = false;
22216         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
22217         return ret_conv;
22218 }
22219
22220 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel"))) TS_ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(uint64_t this_ptr, int8_t val) {
22221         LDKChannelHandshakeConfig this_ptr_conv;
22222         this_ptr_conv.inner = untag_ptr(this_ptr);
22223         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22225         this_ptr_conv.is_owned = false;
22226         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
22227 }
22228
22229 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_get_negotiate_scid_privacy(uint64_t this_ptr) {
22230         LDKChannelHandshakeConfig this_ptr_conv;
22231         this_ptr_conv.inner = untag_ptr(this_ptr);
22232         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22234         this_ptr_conv.is_owned = false;
22235         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
22236         return ret_conv;
22237 }
22238
22239 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_set_negotiate_scid_privacy(uint64_t this_ptr, jboolean val) {
22240         LDKChannelHandshakeConfig this_ptr_conv;
22241         this_ptr_conv.inner = untag_ptr(this_ptr);
22242         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22244         this_ptr_conv.is_owned = false;
22245         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
22246 }
22247
22248 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_announced_channel"))) TS_ChannelHandshakeConfig_get_announced_channel(uint64_t this_ptr) {
22249         LDKChannelHandshakeConfig this_ptr_conv;
22250         this_ptr_conv.inner = untag_ptr(this_ptr);
22251         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22253         this_ptr_conv.is_owned = false;
22254         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
22255         return ret_conv;
22256 }
22257
22258 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_announced_channel"))) TS_ChannelHandshakeConfig_set_announced_channel(uint64_t this_ptr, jboolean val) {
22259         LDKChannelHandshakeConfig this_ptr_conv;
22260         this_ptr_conv.inner = untag_ptr(this_ptr);
22261         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22263         this_ptr_conv.is_owned = false;
22264         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
22265 }
22266
22267 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(uint64_t this_ptr) {
22268         LDKChannelHandshakeConfig this_ptr_conv;
22269         this_ptr_conv.inner = untag_ptr(this_ptr);
22270         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22272         this_ptr_conv.is_owned = false;
22273         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
22274         return ret_conv;
22275 }
22276
22277 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(uint64_t this_ptr, jboolean val) {
22278         LDKChannelHandshakeConfig this_ptr_conv;
22279         this_ptr_conv.inner = untag_ptr(this_ptr);
22280         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22282         this_ptr_conv.is_owned = false;
22283         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
22284 }
22285
22286 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths"))) TS_ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(uint64_t this_ptr) {
22287         LDKChannelHandshakeConfig this_ptr_conv;
22288         this_ptr_conv.inner = untag_ptr(this_ptr);
22289         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22291         this_ptr_conv.is_owned = false;
22292         int32_t ret_conv = ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(&this_ptr_conv);
22293         return ret_conv;
22294 }
22295
22296 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths"))) TS_ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(uint64_t this_ptr, int32_t val) {
22297         LDKChannelHandshakeConfig this_ptr_conv;
22298         this_ptr_conv.inner = untag_ptr(this_ptr);
22299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22301         this_ptr_conv.is_owned = false;
22302         ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(&this_ptr_conv, val);
22303 }
22304
22305 uint64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_new"))) TS_ChannelHandshakeConfig_new(int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg, int8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, jboolean negotiate_scid_privacy_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int32_t their_channel_reserve_proportional_millionths_arg) {
22306         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, their_channel_reserve_proportional_millionths_arg);
22307         uint64_t ret_ref = 0;
22308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22309         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22310         return ret_ref;
22311 }
22312
22313 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
22314         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
22315         uint64_t ret_ref = 0;
22316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22317         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22318         return ret_ref;
22319 }
22320 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint64_t arg) {
22321         LDKChannelHandshakeConfig arg_conv;
22322         arg_conv.inner = untag_ptr(arg);
22323         arg_conv.is_owned = ptr_is_owned(arg);
22324         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22325         arg_conv.is_owned = false;
22326         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
22327         return ret_conv;
22328 }
22329
22330 uint64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint64_t orig) {
22331         LDKChannelHandshakeConfig orig_conv;
22332         orig_conv.inner = untag_ptr(orig);
22333         orig_conv.is_owned = ptr_is_owned(orig);
22334         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22335         orig_conv.is_owned = false;
22336         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
22337         uint64_t ret_ref = 0;
22338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22339         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22340         return ret_ref;
22341 }
22342
22343 uint64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
22344         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
22345         uint64_t ret_ref = 0;
22346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22347         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22348         return ret_ref;
22349 }
22350
22351 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint64_t this_obj) {
22352         LDKChannelHandshakeLimits this_obj_conv;
22353         this_obj_conv.inner = untag_ptr(this_obj);
22354         this_obj_conv.is_owned = ptr_is_owned(this_obj);
22355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22356         ChannelHandshakeLimits_free(this_obj_conv);
22357 }
22358
22359 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint64_t this_ptr) {
22360         LDKChannelHandshakeLimits this_ptr_conv;
22361         this_ptr_conv.inner = untag_ptr(this_ptr);
22362         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22364         this_ptr_conv.is_owned = false;
22365         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
22366         return ret_conv;
22367 }
22368
22369 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint64_t this_ptr, int64_t val) {
22370         LDKChannelHandshakeLimits this_ptr_conv;
22371         this_ptr_conv.inner = untag_ptr(this_ptr);
22372         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22374         this_ptr_conv.is_owned = false;
22375         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
22376 }
22377
22378 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_funding_satoshis"))) TS_ChannelHandshakeLimits_get_max_funding_satoshis(uint64_t this_ptr) {
22379         LDKChannelHandshakeLimits this_ptr_conv;
22380         this_ptr_conv.inner = untag_ptr(this_ptr);
22381         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22383         this_ptr_conv.is_owned = false;
22384         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
22385         return ret_conv;
22386 }
22387
22388 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_funding_satoshis"))) TS_ChannelHandshakeLimits_set_max_funding_satoshis(uint64_t this_ptr, int64_t val) {
22389         LDKChannelHandshakeLimits this_ptr_conv;
22390         this_ptr_conv.inner = untag_ptr(this_ptr);
22391         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22393         this_ptr_conv.is_owned = false;
22394         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
22395 }
22396
22397 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint64_t this_ptr) {
22398         LDKChannelHandshakeLimits this_ptr_conv;
22399         this_ptr_conv.inner = untag_ptr(this_ptr);
22400         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22402         this_ptr_conv.is_owned = false;
22403         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
22404         return ret_conv;
22405 }
22406
22407 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint64_t this_ptr, int64_t val) {
22408         LDKChannelHandshakeLimits this_ptr_conv;
22409         this_ptr_conv.inner = untag_ptr(this_ptr);
22410         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22412         this_ptr_conv.is_owned = false;
22413         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
22414 }
22415
22416 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint64_t this_ptr) {
22417         LDKChannelHandshakeLimits this_ptr_conv;
22418         this_ptr_conv.inner = untag_ptr(this_ptr);
22419         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22421         this_ptr_conv.is_owned = false;
22422         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
22423         return ret_conv;
22424 }
22425
22426 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint64_t this_ptr, int64_t val) {
22427         LDKChannelHandshakeLimits this_ptr_conv;
22428         this_ptr_conv.inner = untag_ptr(this_ptr);
22429         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22431         this_ptr_conv.is_owned = false;
22432         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
22433 }
22434
22435 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint64_t this_ptr) {
22436         LDKChannelHandshakeLimits this_ptr_conv;
22437         this_ptr_conv.inner = untag_ptr(this_ptr);
22438         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22440         this_ptr_conv.is_owned = false;
22441         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
22442         return ret_conv;
22443 }
22444
22445 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint64_t this_ptr, int64_t val) {
22446         LDKChannelHandshakeLimits this_ptr_conv;
22447         this_ptr_conv.inner = untag_ptr(this_ptr);
22448         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22450         this_ptr_conv.is_owned = false;
22451         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
22452 }
22453
22454 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint64_t this_ptr) {
22455         LDKChannelHandshakeLimits this_ptr_conv;
22456         this_ptr_conv.inner = untag_ptr(this_ptr);
22457         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22459         this_ptr_conv.is_owned = false;
22460         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
22461         return ret_conv;
22462 }
22463
22464 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint64_t this_ptr, int16_t val) {
22465         LDKChannelHandshakeLimits this_ptr_conv;
22466         this_ptr_conv.inner = untag_ptr(this_ptr);
22467         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22469         this_ptr_conv.is_owned = false;
22470         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
22471 }
22472
22473 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint64_t this_ptr) {
22474         LDKChannelHandshakeLimits this_ptr_conv;
22475         this_ptr_conv.inner = untag_ptr(this_ptr);
22476         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22478         this_ptr_conv.is_owned = false;
22479         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
22480         return ret_conv;
22481 }
22482
22483 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint64_t this_ptr, int32_t val) {
22484         LDKChannelHandshakeLimits this_ptr_conv;
22485         this_ptr_conv.inner = untag_ptr(this_ptr);
22486         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22488         this_ptr_conv.is_owned = false;
22489         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
22490 }
22491
22492 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_trust_own_funding_0conf"))) TS_ChannelHandshakeLimits_get_trust_own_funding_0conf(uint64_t this_ptr) {
22493         LDKChannelHandshakeLimits this_ptr_conv;
22494         this_ptr_conv.inner = untag_ptr(this_ptr);
22495         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22497         this_ptr_conv.is_owned = false;
22498         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
22499         return ret_conv;
22500 }
22501
22502 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_trust_own_funding_0conf"))) TS_ChannelHandshakeLimits_set_trust_own_funding_0conf(uint64_t this_ptr, jboolean val) {
22503         LDKChannelHandshakeLimits this_ptr_conv;
22504         this_ptr_conv.inner = untag_ptr(this_ptr);
22505         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22507         this_ptr_conv.is_owned = false;
22508         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
22509 }
22510
22511 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint64_t this_ptr) {
22512         LDKChannelHandshakeLimits this_ptr_conv;
22513         this_ptr_conv.inner = untag_ptr(this_ptr);
22514         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22516         this_ptr_conv.is_owned = false;
22517         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
22518         return ret_conv;
22519 }
22520
22521 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint64_t this_ptr, jboolean val) {
22522         LDKChannelHandshakeLimits this_ptr_conv;
22523         this_ptr_conv.inner = untag_ptr(this_ptr);
22524         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22526         this_ptr_conv.is_owned = false;
22527         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
22528 }
22529
22530 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint64_t this_ptr) {
22531         LDKChannelHandshakeLimits this_ptr_conv;
22532         this_ptr_conv.inner = untag_ptr(this_ptr);
22533         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22535         this_ptr_conv.is_owned = false;
22536         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
22537         return ret_conv;
22538 }
22539
22540 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_their_to_self_delay"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint64_t this_ptr, int16_t val) {
22541         LDKChannelHandshakeLimits this_ptr_conv;
22542         this_ptr_conv.inner = untag_ptr(this_ptr);
22543         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22545         this_ptr_conv.is_owned = false;
22546         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
22547 }
22548
22549 uint64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_new"))) TS_ChannelHandshakeLimits_new(int64_t min_funding_satoshis_arg, int64_t max_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 trust_own_funding_0conf_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
22550         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_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, trust_own_funding_0conf_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
22551         uint64_t ret_ref = 0;
22552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22553         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22554         return ret_ref;
22555 }
22556
22557 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
22558         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
22559         uint64_t ret_ref = 0;
22560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22561         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22562         return ret_ref;
22563 }
22564 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint64_t arg) {
22565         LDKChannelHandshakeLimits arg_conv;
22566         arg_conv.inner = untag_ptr(arg);
22567         arg_conv.is_owned = ptr_is_owned(arg);
22568         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22569         arg_conv.is_owned = false;
22570         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
22571         return ret_conv;
22572 }
22573
22574 uint64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint64_t orig) {
22575         LDKChannelHandshakeLimits orig_conv;
22576         orig_conv.inner = untag_ptr(orig);
22577         orig_conv.is_owned = ptr_is_owned(orig);
22578         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22579         orig_conv.is_owned = false;
22580         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
22581         uint64_t ret_ref = 0;
22582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22583         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22584         return ret_ref;
22585 }
22586
22587 uint64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
22588         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
22589         uint64_t ret_ref = 0;
22590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22591         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22592         return ret_ref;
22593 }
22594
22595 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint64_t this_obj) {
22596         LDKChannelConfig this_obj_conv;
22597         this_obj_conv.inner = untag_ptr(this_obj);
22598         this_obj_conv.is_owned = ptr_is_owned(this_obj);
22599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22600         ChannelConfig_free(this_obj_conv);
22601 }
22602
22603 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint64_t this_ptr) {
22604         LDKChannelConfig this_ptr_conv;
22605         this_ptr_conv.inner = untag_ptr(this_ptr);
22606         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22608         this_ptr_conv.is_owned = false;
22609         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
22610         return ret_conv;
22611 }
22612
22613 void  __attribute__((export_name("TS_ChannelConfig_set_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_set_forwarding_fee_proportional_millionths(uint64_t this_ptr, int32_t val) {
22614         LDKChannelConfig this_ptr_conv;
22615         this_ptr_conv.inner = untag_ptr(this_ptr);
22616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22618         this_ptr_conv.is_owned = false;
22619         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
22620 }
22621
22622 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint64_t this_ptr) {
22623         LDKChannelConfig this_ptr_conv;
22624         this_ptr_conv.inner = untag_ptr(this_ptr);
22625         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22627         this_ptr_conv.is_owned = false;
22628         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
22629         return ret_conv;
22630 }
22631
22632 void  __attribute__((export_name("TS_ChannelConfig_set_forwarding_fee_base_msat"))) TS_ChannelConfig_set_forwarding_fee_base_msat(uint64_t this_ptr, int32_t val) {
22633         LDKChannelConfig this_ptr_conv;
22634         this_ptr_conv.inner = untag_ptr(this_ptr);
22635         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22637         this_ptr_conv.is_owned = false;
22638         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
22639 }
22640
22641 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint64_t this_ptr) {
22642         LDKChannelConfig this_ptr_conv;
22643         this_ptr_conv.inner = untag_ptr(this_ptr);
22644         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22646         this_ptr_conv.is_owned = false;
22647         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
22648         return ret_conv;
22649 }
22650
22651 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint64_t this_ptr, int16_t val) {
22652         LDKChannelConfig this_ptr_conv;
22653         this_ptr_conv.inner = untag_ptr(this_ptr);
22654         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22656         this_ptr_conv.is_owned = false;
22657         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
22658 }
22659
22660 int64_t  __attribute__((export_name("TS_ChannelConfig_get_max_dust_htlc_exposure_msat"))) TS_ChannelConfig_get_max_dust_htlc_exposure_msat(uint64_t this_ptr) {
22661         LDKChannelConfig this_ptr_conv;
22662         this_ptr_conv.inner = untag_ptr(this_ptr);
22663         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22665         this_ptr_conv.is_owned = false;
22666         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
22667         return ret_conv;
22668 }
22669
22670 void  __attribute__((export_name("TS_ChannelConfig_set_max_dust_htlc_exposure_msat"))) TS_ChannelConfig_set_max_dust_htlc_exposure_msat(uint64_t this_ptr, int64_t val) {
22671         LDKChannelConfig this_ptr_conv;
22672         this_ptr_conv.inner = untag_ptr(this_ptr);
22673         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22675         this_ptr_conv.is_owned = false;
22676         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
22677 }
22678
22679 int64_t  __attribute__((export_name("TS_ChannelConfig_get_force_close_avoidance_max_fee_satoshis"))) TS_ChannelConfig_get_force_close_avoidance_max_fee_satoshis(uint64_t this_ptr) {
22680         LDKChannelConfig this_ptr_conv;
22681         this_ptr_conv.inner = untag_ptr(this_ptr);
22682         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22684         this_ptr_conv.is_owned = false;
22685         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
22686         return ret_conv;
22687 }
22688
22689 void  __attribute__((export_name("TS_ChannelConfig_set_force_close_avoidance_max_fee_satoshis"))) TS_ChannelConfig_set_force_close_avoidance_max_fee_satoshis(uint64_t this_ptr, int64_t val) {
22690         LDKChannelConfig this_ptr_conv;
22691         this_ptr_conv.inner = untag_ptr(this_ptr);
22692         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22694         this_ptr_conv.is_owned = false;
22695         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
22696 }
22697
22698 uint64_t  __attribute__((export_name("TS_ChannelConfig_new"))) TS_ChannelConfig_new(int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
22699         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
22700         uint64_t ret_ref = 0;
22701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22702         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22703         return ret_ref;
22704 }
22705
22706 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
22707         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
22708         uint64_t ret_ref = 0;
22709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22710         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22711         return ret_ref;
22712 }
22713 int64_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint64_t arg) {
22714         LDKChannelConfig arg_conv;
22715         arg_conv.inner = untag_ptr(arg);
22716         arg_conv.is_owned = ptr_is_owned(arg);
22717         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22718         arg_conv.is_owned = false;
22719         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
22720         return ret_conv;
22721 }
22722
22723 uint64_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint64_t orig) {
22724         LDKChannelConfig orig_conv;
22725         orig_conv.inner = untag_ptr(orig);
22726         orig_conv.is_owned = ptr_is_owned(orig);
22727         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22728         orig_conv.is_owned = false;
22729         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
22730         uint64_t ret_ref = 0;
22731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22732         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22733         return ret_ref;
22734 }
22735
22736 uint64_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
22737         LDKChannelConfig ret_var = ChannelConfig_default();
22738         uint64_t ret_ref = 0;
22739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22740         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22741         return ret_ref;
22742 }
22743
22744 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint64_t obj) {
22745         LDKChannelConfig obj_conv;
22746         obj_conv.inner = untag_ptr(obj);
22747         obj_conv.is_owned = ptr_is_owned(obj);
22748         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22749         obj_conv.is_owned = false;
22750         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
22751         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22752         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22753         CVec_u8Z_free(ret_var);
22754         return ret_arr;
22755 }
22756
22757 uint64_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
22758         LDKu8slice ser_ref;
22759         ser_ref.datalen = ser->arr_len;
22760         ser_ref.data = ser->elems;
22761         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22762         *ret_conv = ChannelConfig_read(ser_ref);
22763         FREE(ser);
22764         return tag_ptr(ret_conv, true);
22765 }
22766
22767 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint64_t this_obj) {
22768         LDKUserConfig this_obj_conv;
22769         this_obj_conv.inner = untag_ptr(this_obj);
22770         this_obj_conv.is_owned = ptr_is_owned(this_obj);
22771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22772         UserConfig_free(this_obj_conv);
22773 }
22774
22775 uint64_t  __attribute__((export_name("TS_UserConfig_get_channel_handshake_config"))) TS_UserConfig_get_channel_handshake_config(uint64_t this_ptr) {
22776         LDKUserConfig this_ptr_conv;
22777         this_ptr_conv.inner = untag_ptr(this_ptr);
22778         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22780         this_ptr_conv.is_owned = false;
22781         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
22782         uint64_t ret_ref = 0;
22783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22784         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22785         return ret_ref;
22786 }
22787
22788 void  __attribute__((export_name("TS_UserConfig_set_channel_handshake_config"))) TS_UserConfig_set_channel_handshake_config(uint64_t this_ptr, uint64_t val) {
22789         LDKUserConfig this_ptr_conv;
22790         this_ptr_conv.inner = untag_ptr(this_ptr);
22791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22793         this_ptr_conv.is_owned = false;
22794         LDKChannelHandshakeConfig val_conv;
22795         val_conv.inner = untag_ptr(val);
22796         val_conv.is_owned = ptr_is_owned(val);
22797         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22798         val_conv = ChannelHandshakeConfig_clone(&val_conv);
22799         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
22800 }
22801
22802 uint64_t  __attribute__((export_name("TS_UserConfig_get_channel_handshake_limits"))) TS_UserConfig_get_channel_handshake_limits(uint64_t this_ptr) {
22803         LDKUserConfig this_ptr_conv;
22804         this_ptr_conv.inner = untag_ptr(this_ptr);
22805         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22807         this_ptr_conv.is_owned = false;
22808         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
22809         uint64_t ret_ref = 0;
22810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22811         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22812         return ret_ref;
22813 }
22814
22815 void  __attribute__((export_name("TS_UserConfig_set_channel_handshake_limits"))) TS_UserConfig_set_channel_handshake_limits(uint64_t this_ptr, uint64_t val) {
22816         LDKUserConfig this_ptr_conv;
22817         this_ptr_conv.inner = untag_ptr(this_ptr);
22818         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22820         this_ptr_conv.is_owned = false;
22821         LDKChannelHandshakeLimits val_conv;
22822         val_conv.inner = untag_ptr(val);
22823         val_conv.is_owned = ptr_is_owned(val);
22824         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22825         val_conv = ChannelHandshakeLimits_clone(&val_conv);
22826         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
22827 }
22828
22829 uint64_t  __attribute__((export_name("TS_UserConfig_get_channel_config"))) TS_UserConfig_get_channel_config(uint64_t this_ptr) {
22830         LDKUserConfig this_ptr_conv;
22831         this_ptr_conv.inner = untag_ptr(this_ptr);
22832         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22834         this_ptr_conv.is_owned = false;
22835         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
22836         uint64_t ret_ref = 0;
22837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22838         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22839         return ret_ref;
22840 }
22841
22842 void  __attribute__((export_name("TS_UserConfig_set_channel_config"))) TS_UserConfig_set_channel_config(uint64_t this_ptr, uint64_t val) {
22843         LDKUserConfig this_ptr_conv;
22844         this_ptr_conv.inner = untag_ptr(this_ptr);
22845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22847         this_ptr_conv.is_owned = false;
22848         LDKChannelConfig val_conv;
22849         val_conv.inner = untag_ptr(val);
22850         val_conv.is_owned = ptr_is_owned(val);
22851         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22852         val_conv = ChannelConfig_clone(&val_conv);
22853         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
22854 }
22855
22856 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint64_t this_ptr) {
22857         LDKUserConfig this_ptr_conv;
22858         this_ptr_conv.inner = untag_ptr(this_ptr);
22859         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22861         this_ptr_conv.is_owned = false;
22862         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
22863         return ret_conv;
22864 }
22865
22866 void  __attribute__((export_name("TS_UserConfig_set_accept_forwards_to_priv_channels"))) TS_UserConfig_set_accept_forwards_to_priv_channels(uint64_t this_ptr, jboolean val) {
22867         LDKUserConfig this_ptr_conv;
22868         this_ptr_conv.inner = untag_ptr(this_ptr);
22869         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22871         this_ptr_conv.is_owned = false;
22872         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
22873 }
22874
22875 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint64_t this_ptr) {
22876         LDKUserConfig this_ptr_conv;
22877         this_ptr_conv.inner = untag_ptr(this_ptr);
22878         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22880         this_ptr_conv.is_owned = false;
22881         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
22882         return ret_conv;
22883 }
22884
22885 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint64_t this_ptr, jboolean val) {
22886         LDKUserConfig this_ptr_conv;
22887         this_ptr_conv.inner = untag_ptr(this_ptr);
22888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22890         this_ptr_conv.is_owned = false;
22891         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
22892 }
22893
22894 jboolean  __attribute__((export_name("TS_UserConfig_get_manually_accept_inbound_channels"))) TS_UserConfig_get_manually_accept_inbound_channels(uint64_t this_ptr) {
22895         LDKUserConfig this_ptr_conv;
22896         this_ptr_conv.inner = untag_ptr(this_ptr);
22897         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22899         this_ptr_conv.is_owned = false;
22900         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
22901         return ret_conv;
22902 }
22903
22904 void  __attribute__((export_name("TS_UserConfig_set_manually_accept_inbound_channels"))) TS_UserConfig_set_manually_accept_inbound_channels(uint64_t this_ptr, jboolean val) {
22905         LDKUserConfig this_ptr_conv;
22906         this_ptr_conv.inner = untag_ptr(this_ptr);
22907         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
22908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22909         this_ptr_conv.is_owned = false;
22910         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
22911 }
22912
22913 uint64_t  __attribute__((export_name("TS_UserConfig_new"))) TS_UserConfig_new(uint64_t channel_handshake_config_arg, uint64_t channel_handshake_limits_arg, uint64_t channel_config_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
22914         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
22915         channel_handshake_config_arg_conv.inner = untag_ptr(channel_handshake_config_arg);
22916         channel_handshake_config_arg_conv.is_owned = ptr_is_owned(channel_handshake_config_arg);
22917         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
22918         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
22919         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
22920         channel_handshake_limits_arg_conv.inner = untag_ptr(channel_handshake_limits_arg);
22921         channel_handshake_limits_arg_conv.is_owned = ptr_is_owned(channel_handshake_limits_arg);
22922         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
22923         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
22924         LDKChannelConfig channel_config_arg_conv;
22925         channel_config_arg_conv.inner = untag_ptr(channel_config_arg);
22926         channel_config_arg_conv.is_owned = ptr_is_owned(channel_config_arg);
22927         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
22928         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
22929         LDKUserConfig ret_var = UserConfig_new(channel_handshake_config_arg_conv, channel_handshake_limits_arg_conv, channel_config_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
22930         uint64_t ret_ref = 0;
22931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22932         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22933         return ret_ref;
22934 }
22935
22936 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
22937         LDKUserConfig ret_var = UserConfig_clone(arg);
22938         uint64_t ret_ref = 0;
22939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22940         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22941         return ret_ref;
22942 }
22943 int64_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint64_t arg) {
22944         LDKUserConfig arg_conv;
22945         arg_conv.inner = untag_ptr(arg);
22946         arg_conv.is_owned = ptr_is_owned(arg);
22947         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22948         arg_conv.is_owned = false;
22949         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
22950         return ret_conv;
22951 }
22952
22953 uint64_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint64_t orig) {
22954         LDKUserConfig orig_conv;
22955         orig_conv.inner = untag_ptr(orig);
22956         orig_conv.is_owned = ptr_is_owned(orig);
22957         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22958         orig_conv.is_owned = false;
22959         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
22960         uint64_t ret_ref = 0;
22961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22962         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22963         return ret_ref;
22964 }
22965
22966 uint64_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
22967         LDKUserConfig ret_var = UserConfig_default();
22968         uint64_t ret_ref = 0;
22969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22970         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22971         return ret_ref;
22972 }
22973
22974 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint64_t this_obj) {
22975         LDKBestBlock this_obj_conv;
22976         this_obj_conv.inner = untag_ptr(this_obj);
22977         this_obj_conv.is_owned = ptr_is_owned(this_obj);
22978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22979         BestBlock_free(this_obj_conv);
22980 }
22981
22982 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
22983         LDKBestBlock ret_var = BestBlock_clone(arg);
22984         uint64_t ret_ref = 0;
22985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22986         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
22987         return ret_ref;
22988 }
22989 int64_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint64_t arg) {
22990         LDKBestBlock arg_conv;
22991         arg_conv.inner = untag_ptr(arg);
22992         arg_conv.is_owned = ptr_is_owned(arg);
22993         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22994         arg_conv.is_owned = false;
22995         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
22996         return ret_conv;
22997 }
22998
22999 uint64_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint64_t orig) {
23000         LDKBestBlock orig_conv;
23001         orig_conv.inner = untag_ptr(orig);
23002         orig_conv.is_owned = ptr_is_owned(orig);
23003         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23004         orig_conv.is_owned = false;
23005         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
23006         uint64_t ret_ref = 0;
23007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23008         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23009         return ret_ref;
23010 }
23011
23012 uint64_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
23013         LDKNetwork network_conv = LDKNetwork_from_js(network);
23014         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
23015         uint64_t ret_ref = 0;
23016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23017         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23018         return ret_ref;
23019 }
23020
23021 uint64_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
23022         LDKThirtyTwoBytes block_hash_ref;
23023         CHECK(block_hash->arr_len == 32);
23024         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
23025         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
23026         uint64_t ret_ref = 0;
23027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23028         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23029         return ret_ref;
23030 }
23031
23032 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint64_t this_arg) {
23033         LDKBestBlock this_arg_conv;
23034         this_arg_conv.inner = untag_ptr(this_arg);
23035         this_arg_conv.is_owned = ptr_is_owned(this_arg);
23036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23037         this_arg_conv.is_owned = false;
23038         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23039         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
23040         return ret_arr;
23041 }
23042
23043 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint64_t this_arg) {
23044         LDKBestBlock this_arg_conv;
23045         this_arg_conv.inner = untag_ptr(this_arg);
23046         this_arg_conv.is_owned = ptr_is_owned(this_arg);
23047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23048         this_arg_conv.is_owned = false;
23049         int32_t ret_conv = BestBlock_height(&this_arg_conv);
23050         return ret_conv;
23051 }
23052
23053 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint64_t orig) {
23054         LDKAccessError* orig_conv = (LDKAccessError*)untag_ptr(orig);
23055         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
23056         return ret_conv;
23057 }
23058
23059 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
23060         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
23061         return ret_conv;
23062 }
23063
23064 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
23065         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
23066         return ret_conv;
23067 }
23068
23069 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint64_t this_ptr) {
23070         if (!ptr_is_owned(this_ptr)) return;
23071         void* this_ptr_ptr = untag_ptr(this_ptr);
23072         CHECK_ACCESS(this_ptr_ptr);
23073         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
23074         FREE(untag_ptr(this_ptr));
23075         Access_free(this_ptr_conv);
23076 }
23077
23078 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint64_t this_ptr) {
23079         if (!ptr_is_owned(this_ptr)) return;
23080         void* this_ptr_ptr = untag_ptr(this_ptr);
23081         CHECK_ACCESS(this_ptr_ptr);
23082         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
23083         FREE(untag_ptr(this_ptr));
23084         Listen_free(this_ptr_conv);
23085 }
23086
23087 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint64_t this_ptr) {
23088         if (!ptr_is_owned(this_ptr)) return;
23089         void* this_ptr_ptr = untag_ptr(this_ptr);
23090         CHECK_ACCESS(this_ptr_ptr);
23091         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
23092         FREE(untag_ptr(this_ptr));
23093         Confirm_free(this_ptr_conv);
23094 }
23095
23096 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint64_t orig) {
23097         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)untag_ptr(orig);
23098         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
23099         return ret_conv;
23100 }
23101
23102 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
23103         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
23104         return ret_conv;
23105 }
23106
23107 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
23108         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
23109         return ret_conv;
23110 }
23111
23112 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint64_t this_ptr) {
23113         if (!ptr_is_owned(this_ptr)) return;
23114         void* this_ptr_ptr = untag_ptr(this_ptr);
23115         CHECK_ACCESS(this_ptr_ptr);
23116         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
23117         FREE(untag_ptr(this_ptr));
23118         Watch_free(this_ptr_conv);
23119 }
23120
23121 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint64_t this_ptr) {
23122         if (!ptr_is_owned(this_ptr)) return;
23123         void* this_ptr_ptr = untag_ptr(this_ptr);
23124         CHECK_ACCESS(this_ptr_ptr);
23125         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
23126         FREE(untag_ptr(this_ptr));
23127         Filter_free(this_ptr_conv);
23128 }
23129
23130 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint64_t this_obj) {
23131         LDKWatchedOutput this_obj_conv;
23132         this_obj_conv.inner = untag_ptr(this_obj);
23133         this_obj_conv.is_owned = ptr_is_owned(this_obj);
23134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23135         WatchedOutput_free(this_obj_conv);
23136 }
23137
23138 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint64_t this_ptr) {
23139         LDKWatchedOutput this_ptr_conv;
23140         this_ptr_conv.inner = untag_ptr(this_ptr);
23141         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
23142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23143         this_ptr_conv.is_owned = false;
23144         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23145         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
23146         return ret_arr;
23147 }
23148
23149 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint64_t this_ptr, int8_tArray val) {
23150         LDKWatchedOutput this_ptr_conv;
23151         this_ptr_conv.inner = untag_ptr(this_ptr);
23152         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
23153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23154         this_ptr_conv.is_owned = false;
23155         LDKThirtyTwoBytes val_ref;
23156         CHECK(val->arr_len == 32);
23157         memcpy(val_ref.data, val->elems, 32); FREE(val);
23158         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
23159 }
23160
23161 uint64_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint64_t this_ptr) {
23162         LDKWatchedOutput this_ptr_conv;
23163         this_ptr_conv.inner = untag_ptr(this_ptr);
23164         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
23165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23166         this_ptr_conv.is_owned = false;
23167         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
23168         uint64_t ret_ref = 0;
23169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23170         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23171         return ret_ref;
23172 }
23173
23174 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint64_t this_ptr, uint64_t val) {
23175         LDKWatchedOutput this_ptr_conv;
23176         this_ptr_conv.inner = untag_ptr(this_ptr);
23177         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
23178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23179         this_ptr_conv.is_owned = false;
23180         LDKOutPoint val_conv;
23181         val_conv.inner = untag_ptr(val);
23182         val_conv.is_owned = ptr_is_owned(val);
23183         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23184         val_conv = OutPoint_clone(&val_conv);
23185         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
23186 }
23187
23188 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint64_t this_ptr) {
23189         LDKWatchedOutput this_ptr_conv;
23190         this_ptr_conv.inner = untag_ptr(this_ptr);
23191         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
23192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23193         this_ptr_conv.is_owned = false;
23194         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
23195         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23196         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23197         return ret_arr;
23198 }
23199
23200 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint64_t this_ptr, int8_tArray val) {
23201         LDKWatchedOutput this_ptr_conv;
23202         this_ptr_conv.inner = untag_ptr(this_ptr);
23203         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
23204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23205         this_ptr_conv.is_owned = false;
23206         LDKCVec_u8Z val_ref;
23207         val_ref.datalen = val->arr_len;
23208         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
23209         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
23210         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
23211 }
23212
23213 uint64_t  __attribute__((export_name("TS_WatchedOutput_new"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint64_t outpoint_arg, int8_tArray script_pubkey_arg) {
23214         LDKThirtyTwoBytes block_hash_arg_ref;
23215         CHECK(block_hash_arg->arr_len == 32);
23216         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
23217         LDKOutPoint outpoint_arg_conv;
23218         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
23219         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
23220         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23221         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23222         LDKCVec_u8Z script_pubkey_arg_ref;
23223         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
23224         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
23225         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
23226         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
23227         uint64_t ret_ref = 0;
23228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23229         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23230         return ret_ref;
23231 }
23232
23233 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
23234         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
23235         uint64_t ret_ref = 0;
23236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23237         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23238         return ret_ref;
23239 }
23240 int64_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint64_t arg) {
23241         LDKWatchedOutput arg_conv;
23242         arg_conv.inner = untag_ptr(arg);
23243         arg_conv.is_owned = ptr_is_owned(arg);
23244         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23245         arg_conv.is_owned = false;
23246         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
23247         return ret_conv;
23248 }
23249
23250 uint64_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint64_t orig) {
23251         LDKWatchedOutput orig_conv;
23252         orig_conv.inner = untag_ptr(orig);
23253         orig_conv.is_owned = ptr_is_owned(orig);
23254         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23255         orig_conv.is_owned = false;
23256         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
23257         uint64_t ret_ref = 0;
23258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23260         return ret_ref;
23261 }
23262
23263 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint64_t o) {
23264         LDKWatchedOutput o_conv;
23265         o_conv.inner = untag_ptr(o);
23266         o_conv.is_owned = ptr_is_owned(o);
23267         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23268         o_conv.is_owned = false;
23269         int64_t ret_conv = WatchedOutput_hash(&o_conv);
23270         return ret_conv;
23271 }
23272
23273 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint64_t this_ptr) {
23274         if (!ptr_is_owned(this_ptr)) return;
23275         void* this_ptr_ptr = untag_ptr(this_ptr);
23276         CHECK_ACCESS(this_ptr_ptr);
23277         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
23278         FREE(untag_ptr(this_ptr));
23279         BroadcasterInterface_free(this_ptr_conv);
23280 }
23281
23282 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint64_t orig) {
23283         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)untag_ptr(orig);
23284         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
23285         return ret_conv;
23286 }
23287
23288 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
23289         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
23290         return ret_conv;
23291 }
23292
23293 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
23294         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
23295         return ret_conv;
23296 }
23297
23298 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
23299         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
23300         return ret_conv;
23301 }
23302
23303 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint64_t a, uint64_t b) {
23304         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)untag_ptr(a);
23305         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)untag_ptr(b);
23306         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
23307         return ret_conv;
23308 }
23309
23310 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint64_t this_ptr) {
23311         if (!ptr_is_owned(this_ptr)) return;
23312         void* this_ptr_ptr = untag_ptr(this_ptr);
23313         CHECK_ACCESS(this_ptr_ptr);
23314         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
23315         FREE(untag_ptr(this_ptr));
23316         FeeEstimator_free(this_ptr_conv);
23317 }
23318
23319 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint64_t this_obj) {
23320         LDKMonitorUpdateId this_obj_conv;
23321         this_obj_conv.inner = untag_ptr(this_obj);
23322         this_obj_conv.is_owned = ptr_is_owned(this_obj);
23323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23324         MonitorUpdateId_free(this_obj_conv);
23325 }
23326
23327 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
23328         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
23329         uint64_t ret_ref = 0;
23330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23331         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23332         return ret_ref;
23333 }
23334 int64_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint64_t arg) {
23335         LDKMonitorUpdateId arg_conv;
23336         arg_conv.inner = untag_ptr(arg);
23337         arg_conv.is_owned = ptr_is_owned(arg);
23338         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23339         arg_conv.is_owned = false;
23340         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
23341         return ret_conv;
23342 }
23343
23344 uint64_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint64_t orig) {
23345         LDKMonitorUpdateId orig_conv;
23346         orig_conv.inner = untag_ptr(orig);
23347         orig_conv.is_owned = ptr_is_owned(orig);
23348         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23349         orig_conv.is_owned = false;
23350         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
23351         uint64_t ret_ref = 0;
23352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23353         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23354         return ret_ref;
23355 }
23356
23357 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint64_t o) {
23358         LDKMonitorUpdateId o_conv;
23359         o_conv.inner = untag_ptr(o);
23360         o_conv.is_owned = ptr_is_owned(o);
23361         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23362         o_conv.is_owned = false;
23363         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
23364         return ret_conv;
23365 }
23366
23367 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint64_t a, uint64_t b) {
23368         LDKMonitorUpdateId a_conv;
23369         a_conv.inner = untag_ptr(a);
23370         a_conv.is_owned = ptr_is_owned(a);
23371         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23372         a_conv.is_owned = false;
23373         LDKMonitorUpdateId b_conv;
23374         b_conv.inner = untag_ptr(b);
23375         b_conv.is_owned = ptr_is_owned(b);
23376         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
23377         b_conv.is_owned = false;
23378         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
23379         return ret_conv;
23380 }
23381
23382 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint64_t this_ptr) {
23383         if (!ptr_is_owned(this_ptr)) return;
23384         void* this_ptr_ptr = untag_ptr(this_ptr);
23385         CHECK_ACCESS(this_ptr_ptr);
23386         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
23387         FREE(untag_ptr(this_ptr));
23388         Persist_free(this_ptr_conv);
23389 }
23390
23391 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint64_t this_obj) {
23392         LDKLockedChannelMonitor this_obj_conv;
23393         this_obj_conv.inner = untag_ptr(this_obj);
23394         this_obj_conv.is_owned = ptr_is_owned(this_obj);
23395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23396         LockedChannelMonitor_free(this_obj_conv);
23397 }
23398
23399 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint64_t this_obj) {
23400         LDKChainMonitor this_obj_conv;
23401         this_obj_conv.inner = untag_ptr(this_obj);
23402         this_obj_conv.is_owned = ptr_is_owned(this_obj);
23403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23404         ChainMonitor_free(this_obj_conv);
23405 }
23406
23407 uint64_t  __attribute__((export_name("TS_ChainMonitor_new"))) TS_ChainMonitor_new(uint64_t chain_source, uint64_t broadcaster, uint64_t logger, uint64_t feeest, uint64_t persister) {
23408         void* chain_source_ptr = untag_ptr(chain_source);
23409         CHECK_ACCESS(chain_source_ptr);
23410         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
23411         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
23412         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
23413                 // Manually implement clone for Java trait instances
23414                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
23415                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23416                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
23417                 }
23418         }
23419         void* broadcaster_ptr = untag_ptr(broadcaster);
23420         CHECK_ACCESS(broadcaster_ptr);
23421         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23422         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23423                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23424                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23425         }
23426         void* logger_ptr = untag_ptr(logger);
23427         CHECK_ACCESS(logger_ptr);
23428         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23429         if (logger_conv.free == LDKLogger_JCalls_free) {
23430                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23431                 LDKLogger_JCalls_cloned(&logger_conv);
23432         }
23433         void* feeest_ptr = untag_ptr(feeest);
23434         CHECK_ACCESS(feeest_ptr);
23435         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
23436         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
23437                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23438                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
23439         }
23440         void* persister_ptr = untag_ptr(persister);
23441         CHECK_ACCESS(persister_ptr);
23442         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
23443         if (persister_conv.free == LDKPersist_JCalls_free) {
23444                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23445                 LDKPersist_JCalls_cloned(&persister_conv);
23446         }
23447         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
23448         uint64_t ret_ref = 0;
23449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23450         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23451         return ret_ref;
23452 }
23453
23454 uint64_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint64_t this_arg, uint64_tArray ignored_channels) {
23455         LDKChainMonitor this_arg_conv;
23456         this_arg_conv.inner = untag_ptr(this_arg);
23457         this_arg_conv.is_owned = ptr_is_owned(this_arg);
23458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23459         this_arg_conv.is_owned = false;
23460         LDKCVec_ChannelDetailsZ ignored_channels_constr;
23461         ignored_channels_constr.datalen = ignored_channels->arr_len;
23462         if (ignored_channels_constr.datalen > 0)
23463                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23464         else
23465                 ignored_channels_constr.data = NULL;
23466         uint64_t* ignored_channels_vals = ignored_channels->elems;
23467         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
23468                 uint64_t ignored_channels_conv_16 = ignored_channels_vals[q];
23469                 LDKChannelDetails ignored_channels_conv_16_conv;
23470                 ignored_channels_conv_16_conv.inner = untag_ptr(ignored_channels_conv_16);
23471                 ignored_channels_conv_16_conv.is_owned = ptr_is_owned(ignored_channels_conv_16);
23472                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
23473                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
23474                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
23475         }
23476         FREE(ignored_channels);
23477         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
23478         uint64_tArray ret_arr = NULL;
23479         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
23480         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
23481         for (size_t j = 0; j < ret_var.datalen; j++) {
23482                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23483                 *ret_conv_9_copy = ret_var.data[j];
23484                 uint64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
23485                 ret_arr_ptr[j] = ret_conv_9_ref;
23486         }
23487         
23488         FREE(ret_var.data);
23489         return ret_arr;
23490 }
23491
23492 uint64_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint64_t this_arg, uint64_t funding_txo) {
23493         LDKChainMonitor this_arg_conv;
23494         this_arg_conv.inner = untag_ptr(this_arg);
23495         this_arg_conv.is_owned = ptr_is_owned(this_arg);
23496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23497         this_arg_conv.is_owned = false;
23498         LDKOutPoint funding_txo_conv;
23499         funding_txo_conv.inner = untag_ptr(funding_txo);
23500         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
23501         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23502         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23503         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23504         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
23505         return tag_ptr(ret_conv, true);
23506 }
23507
23508 uint64_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint64_t this_arg) {
23509         LDKChainMonitor this_arg_conv;
23510         this_arg_conv.inner = untag_ptr(this_arg);
23511         this_arg_conv.is_owned = ptr_is_owned(this_arg);
23512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23513         this_arg_conv.is_owned = false;
23514         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
23515         uint64_tArray ret_arr = NULL;
23516         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
23517         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
23518         for (size_t k = 0; k < ret_var.datalen; k++) {
23519                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
23520                 uint64_t ret_conv_10_ref = 0;
23521                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
23522                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
23523                 ret_arr_ptr[k] = ret_conv_10_ref;
23524         }
23525         
23526         FREE(ret_var.data);
23527         return ret_arr;
23528 }
23529
23530 uint64_t  __attribute__((export_name("TS_ChainMonitor_channel_monitor_updated"))) TS_ChainMonitor_channel_monitor_updated(uint64_t this_arg, uint64_t funding_txo, uint64_t completed_update_id) {
23531         LDKChainMonitor this_arg_conv;
23532         this_arg_conv.inner = untag_ptr(this_arg);
23533         this_arg_conv.is_owned = ptr_is_owned(this_arg);
23534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23535         this_arg_conv.is_owned = false;
23536         LDKOutPoint funding_txo_conv;
23537         funding_txo_conv.inner = untag_ptr(funding_txo);
23538         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
23539         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23540         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23541         LDKMonitorUpdateId completed_update_id_conv;
23542         completed_update_id_conv.inner = untag_ptr(completed_update_id);
23543         completed_update_id_conv.is_owned = ptr_is_owned(completed_update_id);
23544         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
23545         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
23546         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
23547         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
23548         return tag_ptr(ret_conv, true);
23549 }
23550
23551 uint64_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint64_t this_arg) {
23552         LDKChainMonitor this_arg_conv;
23553         this_arg_conv.inner = untag_ptr(this_arg);
23554         this_arg_conv.is_owned = ptr_is_owned(this_arg);
23555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23556         this_arg_conv.is_owned = false;
23557         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
23558         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
23559         return tag_ptr(ret_ret, true);
23560 }
23561
23562 uint64_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint64_t this_arg) {
23563         LDKChainMonitor this_arg_conv;
23564         this_arg_conv.inner = untag_ptr(this_arg);
23565         this_arg_conv.is_owned = ptr_is_owned(this_arg);
23566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23567         this_arg_conv.is_owned = false;
23568         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
23569         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
23570         return tag_ptr(ret_ret, true);
23571 }
23572
23573 uint64_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint64_t this_arg) {
23574         LDKChainMonitor this_arg_conv;
23575         this_arg_conv.inner = untag_ptr(this_arg);
23576         this_arg_conv.is_owned = ptr_is_owned(this_arg);
23577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23578         this_arg_conv.is_owned = false;
23579         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
23580         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
23581         return tag_ptr(ret_ret, true);
23582 }
23583
23584 uint64_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint64_t this_arg) {
23585         LDKChainMonitor this_arg_conv;
23586         this_arg_conv.inner = untag_ptr(this_arg);
23587         this_arg_conv.is_owned = ptr_is_owned(this_arg);
23588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23589         this_arg_conv.is_owned = false;
23590         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
23591         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
23592         return tag_ptr(ret_ret, true);
23593 }
23594
23595 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint64_t this_obj) {
23596         LDKChannelMonitorUpdate this_obj_conv;
23597         this_obj_conv.inner = untag_ptr(this_obj);
23598         this_obj_conv.is_owned = ptr_is_owned(this_obj);
23599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23600         ChannelMonitorUpdate_free(this_obj_conv);
23601 }
23602
23603 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint64_t this_ptr) {
23604         LDKChannelMonitorUpdate this_ptr_conv;
23605         this_ptr_conv.inner = untag_ptr(this_ptr);
23606         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
23607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23608         this_ptr_conv.is_owned = false;
23609         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
23610         return ret_conv;
23611 }
23612
23613 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint64_t this_ptr, int64_t val) {
23614         LDKChannelMonitorUpdate this_ptr_conv;
23615         this_ptr_conv.inner = untag_ptr(this_ptr);
23616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
23617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23618         this_ptr_conv.is_owned = false;
23619         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
23620 }
23621
23622 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
23623         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
23624         uint64_t ret_ref = 0;
23625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23626         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23627         return ret_ref;
23628 }
23629 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint64_t arg) {
23630         LDKChannelMonitorUpdate arg_conv;
23631         arg_conv.inner = untag_ptr(arg);
23632         arg_conv.is_owned = ptr_is_owned(arg);
23633         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23634         arg_conv.is_owned = false;
23635         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
23636         return ret_conv;
23637 }
23638
23639 uint64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint64_t orig) {
23640         LDKChannelMonitorUpdate orig_conv;
23641         orig_conv.inner = untag_ptr(orig);
23642         orig_conv.is_owned = ptr_is_owned(orig);
23643         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23644         orig_conv.is_owned = false;
23645         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
23646         uint64_t ret_ref = 0;
23647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23648         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23649         return ret_ref;
23650 }
23651
23652 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint64_t obj) {
23653         LDKChannelMonitorUpdate obj_conv;
23654         obj_conv.inner = untag_ptr(obj);
23655         obj_conv.is_owned = ptr_is_owned(obj);
23656         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23657         obj_conv.is_owned = false;
23658         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
23659         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23660         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23661         CVec_u8Z_free(ret_var);
23662         return ret_arr;
23663 }
23664
23665 uint64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
23666         LDKu8slice ser_ref;
23667         ser_ref.datalen = ser->arr_len;
23668         ser_ref.data = ser->elems;
23669         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
23670         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
23671         FREE(ser);
23672         return tag_ptr(ret_conv, true);
23673 }
23674
23675 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint64_t this_ptr) {
23676         if (!ptr_is_owned(this_ptr)) return;
23677         void* this_ptr_ptr = untag_ptr(this_ptr);
23678         CHECK_ACCESS(this_ptr_ptr);
23679         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
23680         FREE(untag_ptr(this_ptr));
23681         MonitorEvent_free(this_ptr_conv);
23682 }
23683
23684 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
23685         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23686         *ret_copy = MonitorEvent_clone(arg);
23687         uint64_t ret_ref = tag_ptr(ret_copy, true);
23688         return ret_ref;
23689 }
23690 int64_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint64_t arg) {
23691         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)untag_ptr(arg);
23692         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
23693         return ret_conv;
23694 }
23695
23696 uint64_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint64_t orig) {
23697         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)untag_ptr(orig);
23698         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23699         *ret_copy = MonitorEvent_clone(orig_conv);
23700         uint64_t ret_ref = tag_ptr(ret_copy, true);
23701         return ret_ref;
23702 }
23703
23704 uint64_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint64_t a) {
23705         LDKHTLCUpdate a_conv;
23706         a_conv.inner = untag_ptr(a);
23707         a_conv.is_owned = ptr_is_owned(a);
23708         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23709         a_conv = HTLCUpdate_clone(&a_conv);
23710         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23711         *ret_copy = MonitorEvent_htlcevent(a_conv);
23712         uint64_t ret_ref = tag_ptr(ret_copy, true);
23713         return ret_ref;
23714 }
23715
23716 uint64_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint64_t a) {
23717         LDKOutPoint a_conv;
23718         a_conv.inner = untag_ptr(a);
23719         a_conv.is_owned = ptr_is_owned(a);
23720         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23721         a_conv = OutPoint_clone(&a_conv);
23722         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23723         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
23724         uint64_t ret_ref = tag_ptr(ret_copy, true);
23725         return ret_ref;
23726 }
23727
23728 uint64_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint64_t funding_txo, int64_t monitor_update_id) {
23729         LDKOutPoint funding_txo_conv;
23730         funding_txo_conv.inner = untag_ptr(funding_txo);
23731         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
23732         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23733         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23734         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23735         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
23736         uint64_t ret_ref = tag_ptr(ret_copy, true);
23737         return ret_ref;
23738 }
23739
23740 uint64_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint64_t a) {
23741         LDKOutPoint a_conv;
23742         a_conv.inner = untag_ptr(a);
23743         a_conv.is_owned = ptr_is_owned(a);
23744         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23745         a_conv = OutPoint_clone(&a_conv);
23746         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23747         *ret_copy = MonitorEvent_update_failed(a_conv);
23748         uint64_t ret_ref = tag_ptr(ret_copy, true);
23749         return ret_ref;
23750 }
23751
23752 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint64_t obj) {
23753         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)untag_ptr(obj);
23754         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
23755         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23756         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23757         CVec_u8Z_free(ret_var);
23758         return ret_arr;
23759 }
23760
23761 uint64_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
23762         LDKu8slice ser_ref;
23763         ser_ref.datalen = ser->arr_len;
23764         ser_ref.data = ser->elems;
23765         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23766         *ret_conv = MonitorEvent_read(ser_ref);
23767         FREE(ser);
23768         return tag_ptr(ret_conv, true);
23769 }
23770
23771 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint64_t this_obj) {
23772         LDKHTLCUpdate this_obj_conv;
23773         this_obj_conv.inner = untag_ptr(this_obj);
23774         this_obj_conv.is_owned = ptr_is_owned(this_obj);
23775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23776         HTLCUpdate_free(this_obj_conv);
23777 }
23778
23779 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
23780         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
23781         uint64_t ret_ref = 0;
23782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23783         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23784         return ret_ref;
23785 }
23786 int64_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint64_t arg) {
23787         LDKHTLCUpdate arg_conv;
23788         arg_conv.inner = untag_ptr(arg);
23789         arg_conv.is_owned = ptr_is_owned(arg);
23790         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23791         arg_conv.is_owned = false;
23792         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
23793         return ret_conv;
23794 }
23795
23796 uint64_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint64_t orig) {
23797         LDKHTLCUpdate orig_conv;
23798         orig_conv.inner = untag_ptr(orig);
23799         orig_conv.is_owned = ptr_is_owned(orig);
23800         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23801         orig_conv.is_owned = false;
23802         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
23803         uint64_t ret_ref = 0;
23804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23805         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23806         return ret_ref;
23807 }
23808
23809 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint64_t obj) {
23810         LDKHTLCUpdate obj_conv;
23811         obj_conv.inner = untag_ptr(obj);
23812         obj_conv.is_owned = ptr_is_owned(obj);
23813         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23814         obj_conv.is_owned = false;
23815         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
23816         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23817         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23818         CVec_u8Z_free(ret_var);
23819         return ret_arr;
23820 }
23821
23822 uint64_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
23823         LDKu8slice ser_ref;
23824         ser_ref.datalen = ser->arr_len;
23825         ser_ref.data = ser->elems;
23826         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23827         *ret_conv = HTLCUpdate_read(ser_ref);
23828         FREE(ser);
23829         return tag_ptr(ret_conv, true);
23830 }
23831
23832 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint64_t this_ptr) {
23833         if (!ptr_is_owned(this_ptr)) return;
23834         void* this_ptr_ptr = untag_ptr(this_ptr);
23835         CHECK_ACCESS(this_ptr_ptr);
23836         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
23837         FREE(untag_ptr(this_ptr));
23838         Balance_free(this_ptr_conv);
23839 }
23840
23841 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
23842         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23843         *ret_copy = Balance_clone(arg);
23844         uint64_t ret_ref = tag_ptr(ret_copy, true);
23845         return ret_ref;
23846 }
23847 int64_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint64_t arg) {
23848         LDKBalance* arg_conv = (LDKBalance*)untag_ptr(arg);
23849         int64_t ret_conv = Balance_clone_ptr(arg_conv);
23850         return ret_conv;
23851 }
23852
23853 uint64_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint64_t orig) {
23854         LDKBalance* orig_conv = (LDKBalance*)untag_ptr(orig);
23855         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23856         *ret_copy = Balance_clone(orig_conv);
23857         uint64_t ret_ref = tag_ptr(ret_copy, true);
23858         return ret_ref;
23859 }
23860
23861 uint64_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
23862         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23863         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
23864         uint64_t ret_ref = tag_ptr(ret_copy, true);
23865         return ret_ref;
23866 }
23867
23868 uint64_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
23869         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23870         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
23871         uint64_t ret_ref = tag_ptr(ret_copy, true);
23872         return ret_ref;
23873 }
23874
23875 uint64_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
23876         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23877         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
23878         uint64_t ret_ref = tag_ptr(ret_copy, true);
23879         return ret_ref;
23880 }
23881
23882 uint64_t  __attribute__((export_name("TS_Balance_maybe_timeout_claimable_htlc"))) TS_Balance_maybe_timeout_claimable_htlc(int64_t claimable_amount_satoshis, int32_t claimable_height) {
23883         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23884         *ret_copy = Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis, claimable_height);
23885         uint64_t ret_ref = tag_ptr(ret_copy, true);
23886         return ret_ref;
23887 }
23888
23889 uint64_t  __attribute__((export_name("TS_Balance_maybe_preimage_claimable_htlc"))) TS_Balance_maybe_preimage_claimable_htlc(int64_t claimable_amount_satoshis, int32_t expiry_height) {
23890         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23891         *ret_copy = Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis, expiry_height);
23892         uint64_t ret_ref = tag_ptr(ret_copy, true);
23893         return ret_ref;
23894 }
23895
23896 uint64_t  __attribute__((export_name("TS_Balance_counterparty_revoked_output_claimable"))) TS_Balance_counterparty_revoked_output_claimable(int64_t claimable_amount_satoshis) {
23897         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23898         *ret_copy = Balance_counterparty_revoked_output_claimable(claimable_amount_satoshis);
23899         uint64_t ret_ref = tag_ptr(ret_copy, true);
23900         return ret_ref;
23901 }
23902
23903 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint64_t a, uint64_t b) {
23904         LDKBalance* a_conv = (LDKBalance*)untag_ptr(a);
23905         LDKBalance* b_conv = (LDKBalance*)untag_ptr(b);
23906         jboolean ret_conv = Balance_eq(a_conv, b_conv);
23907         return ret_conv;
23908 }
23909
23910 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint64_t this_obj) {
23911         LDKChannelMonitor this_obj_conv;
23912         this_obj_conv.inner = untag_ptr(this_obj);
23913         this_obj_conv.is_owned = ptr_is_owned(this_obj);
23914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23915         ChannelMonitor_free(this_obj_conv);
23916 }
23917
23918 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
23919         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
23920         uint64_t ret_ref = 0;
23921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23922         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23923         return ret_ref;
23924 }
23925 int64_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint64_t arg) {
23926         LDKChannelMonitor arg_conv;
23927         arg_conv.inner = untag_ptr(arg);
23928         arg_conv.is_owned = ptr_is_owned(arg);
23929         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23930         arg_conv.is_owned = false;
23931         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
23932         return ret_conv;
23933 }
23934
23935 uint64_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint64_t orig) {
23936         LDKChannelMonitor orig_conv;
23937         orig_conv.inner = untag_ptr(orig);
23938         orig_conv.is_owned = ptr_is_owned(orig);
23939         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23940         orig_conv.is_owned = false;
23941         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
23942         uint64_t ret_ref = 0;
23943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23944         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
23945         return ret_ref;
23946 }
23947
23948 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint64_t obj) {
23949         LDKChannelMonitor obj_conv;
23950         obj_conv.inner = untag_ptr(obj);
23951         obj_conv.is_owned = ptr_is_owned(obj);
23952         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23953         obj_conv.is_owned = false;
23954         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
23955         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23956         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23957         CVec_u8Z_free(ret_var);
23958         return ret_arr;
23959 }
23960
23961 uint64_t  __attribute__((export_name("TS_ChannelMonitor_update_monitor"))) TS_ChannelMonitor_update_monitor(uint64_t this_arg, uint64_t updates, uint64_t broadcaster, uint64_t fee_estimator, uint64_t logger) {
23962         LDKChannelMonitor this_arg_conv;
23963         this_arg_conv.inner = untag_ptr(this_arg);
23964         this_arg_conv.is_owned = ptr_is_owned(this_arg);
23965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23966         this_arg_conv.is_owned = false;
23967         LDKChannelMonitorUpdate updates_conv;
23968         updates_conv.inner = untag_ptr(updates);
23969         updates_conv.is_owned = ptr_is_owned(updates);
23970         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
23971         updates_conv.is_owned = false;
23972         void* broadcaster_ptr = untag_ptr(broadcaster);
23973         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
23974         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
23975         void* fee_estimator_ptr = untag_ptr(fee_estimator);
23976         CHECK_ACCESS(fee_estimator_ptr);
23977         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23978         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23979                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23980                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23981         }
23982         void* logger_ptr = untag_ptr(logger);
23983         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
23984         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
23985         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
23986         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
23987         return tag_ptr(ret_conv, true);
23988 }
23989
23990 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint64_t this_arg) {
23991         LDKChannelMonitor this_arg_conv;
23992         this_arg_conv.inner = untag_ptr(this_arg);
23993         this_arg_conv.is_owned = ptr_is_owned(this_arg);
23994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23995         this_arg_conv.is_owned = false;
23996         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
23997         return ret_conv;
23998 }
23999
24000 uint64_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint64_t this_arg) {
24001         LDKChannelMonitor this_arg_conv;
24002         this_arg_conv.inner = untag_ptr(this_arg);
24003         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24005         this_arg_conv.is_owned = false;
24006         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
24007         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
24008         return tag_ptr(ret_conv, true);
24009 }
24010
24011 uint64_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint64_t this_arg) {
24012         LDKChannelMonitor this_arg_conv;
24013         this_arg_conv.inner = untag_ptr(this_arg);
24014         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24016         this_arg_conv.is_owned = false;
24017         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
24018         uint64_tArray ret_arr = NULL;
24019         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
24020         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
24021         for (size_t o = 0; o < ret_var.datalen; o++) {
24022                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
24023                 *ret_conv_40_conv = ret_var.data[o];
24024                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
24025         }
24026         
24027         FREE(ret_var.data);
24028         return ret_arr;
24029 }
24030
24031 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint64_t this_arg, uint64_t filter) {
24032         LDKChannelMonitor this_arg_conv;
24033         this_arg_conv.inner = untag_ptr(this_arg);
24034         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24036         this_arg_conv.is_owned = false;
24037         void* filter_ptr = untag_ptr(filter);
24038         if (ptr_is_owned(filter)) { CHECK_ACCESS(filter_ptr); }
24039         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
24040         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
24041 }
24042
24043 uint64_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_monitor_events"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint64_t this_arg) {
24044         LDKChannelMonitor this_arg_conv;
24045         this_arg_conv.inner = untag_ptr(this_arg);
24046         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24048         this_arg_conv.is_owned = false;
24049         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
24050         uint64_tArray ret_arr = NULL;
24051         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
24052         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
24053         for (size_t o = 0; o < ret_var.datalen; o++) {
24054                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
24055                 *ret_conv_14_copy = ret_var.data[o];
24056                 uint64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
24057                 ret_arr_ptr[o] = ret_conv_14_ref;
24058         }
24059         
24060         FREE(ret_var.data);
24061         return ret_arr;
24062 }
24063
24064 uint64_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint64_t this_arg) {
24065         LDKChannelMonitor this_arg_conv;
24066         this_arg_conv.inner = untag_ptr(this_arg);
24067         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24069         this_arg_conv.is_owned = false;
24070         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
24071         uint64_tArray ret_arr = NULL;
24072         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
24073         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
24074         for (size_t h = 0; h < ret_var.datalen; h++) {
24075                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24076                 *ret_conv_7_copy = ret_var.data[h];
24077                 uint64_t ret_conv_7_ref = tag_ptr(ret_conv_7_copy, true);
24078                 ret_arr_ptr[h] = ret_conv_7_ref;
24079         }
24080         
24081         FREE(ret_var.data);
24082         return ret_arr;
24083 }
24084
24085 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_get_counterparty_node_id"))) TS_ChannelMonitor_get_counterparty_node_id(uint64_t this_arg) {
24086         LDKChannelMonitor this_arg_conv;
24087         this_arg_conv.inner = untag_ptr(this_arg);
24088         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24090         this_arg_conv.is_owned = false;
24091         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24092         memcpy(ret_arr->elems, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form, 33);
24093         return ret_arr;
24094 }
24095
24096 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_latest_holder_commitment_txn"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint64_t this_arg, uint64_t logger) {
24097         LDKChannelMonitor this_arg_conv;
24098         this_arg_conv.inner = untag_ptr(this_arg);
24099         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24101         this_arg_conv.is_owned = false;
24102         void* logger_ptr = untag_ptr(logger);
24103         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
24104         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
24105         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
24106         ptrArray ret_arr = NULL;
24107         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
24108         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
24109         for (size_t m = 0; m < ret_var.datalen; m++) {
24110                 LDKTransaction ret_conv_12_var = ret_var.data[m];
24111                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
24112                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
24113                 Transaction_free(ret_conv_12_var);
24114                 ret_arr_ptr[m] = ret_conv_12_arr;
24115         }
24116         
24117         FREE(ret_var.data);
24118         return ret_arr;
24119 }
24120
24121 uint64_tArray  __attribute__((export_name("TS_ChannelMonitor_block_connected"))) TS_ChannelMonitor_block_connected(uint64_t this_arg, int8_tArray header, uint64_tArray txdata, int32_t height, uint64_t broadcaster, uint64_t fee_estimator, uint64_t logger) {
24122         LDKChannelMonitor this_arg_conv;
24123         this_arg_conv.inner = untag_ptr(this_arg);
24124         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24126         this_arg_conv.is_owned = false;
24127         unsigned char header_arr[80];
24128         CHECK(header->arr_len == 80);
24129         memcpy(header_arr, header->elems, 80); FREE(header);
24130         unsigned char (*header_ref)[80] = &header_arr;
24131         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
24132         txdata_constr.datalen = txdata->arr_len;
24133         if (txdata_constr.datalen > 0)
24134                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
24135         else
24136                 txdata_constr.data = NULL;
24137         uint64_t* txdata_vals = txdata->elems;
24138         for (size_t c = 0; c < txdata_constr.datalen; c++) {
24139                 uint64_t txdata_conv_28 = txdata_vals[c];
24140                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
24141                 CHECK_ACCESS(txdata_conv_28_ptr);
24142                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
24143                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
24144                 txdata_constr.data[c] = txdata_conv_28_conv;
24145         }
24146         FREE(txdata);
24147         void* broadcaster_ptr = untag_ptr(broadcaster);
24148         CHECK_ACCESS(broadcaster_ptr);
24149         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24150         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24151                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24152                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24153         }
24154         void* fee_estimator_ptr = untag_ptr(fee_estimator);
24155         CHECK_ACCESS(fee_estimator_ptr);
24156         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24157         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24158                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24159                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24160         }
24161         void* logger_ptr = untag_ptr(logger);
24162         CHECK_ACCESS(logger_ptr);
24163         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24164         if (logger_conv.free == LDKLogger_JCalls_free) {
24165                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24166                 LDKLogger_JCalls_cloned(&logger_conv);
24167         }
24168         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);
24169         uint64_tArray ret_arr = NULL;
24170         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
24171         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
24172         for (size_t n = 0; n < ret_var.datalen; n++) {
24173                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24174                 *ret_conv_39_conv = ret_var.data[n];
24175                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
24176         }
24177         
24178         FREE(ret_var.data);
24179         return ret_arr;
24180 }
24181
24182 void  __attribute__((export_name("TS_ChannelMonitor_block_disconnected"))) TS_ChannelMonitor_block_disconnected(uint64_t this_arg, int8_tArray header, int32_t height, uint64_t broadcaster, uint64_t fee_estimator, uint64_t logger) {
24183         LDKChannelMonitor this_arg_conv;
24184         this_arg_conv.inner = untag_ptr(this_arg);
24185         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24187         this_arg_conv.is_owned = false;
24188         unsigned char header_arr[80];
24189         CHECK(header->arr_len == 80);
24190         memcpy(header_arr, header->elems, 80); FREE(header);
24191         unsigned char (*header_ref)[80] = &header_arr;
24192         void* broadcaster_ptr = untag_ptr(broadcaster);
24193         CHECK_ACCESS(broadcaster_ptr);
24194         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24195         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24196                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24197                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24198         }
24199         void* fee_estimator_ptr = untag_ptr(fee_estimator);
24200         CHECK_ACCESS(fee_estimator_ptr);
24201         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24202         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24203                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24204                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24205         }
24206         void* logger_ptr = untag_ptr(logger);
24207         CHECK_ACCESS(logger_ptr);
24208         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24209         if (logger_conv.free == LDKLogger_JCalls_free) {
24210                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24211                 LDKLogger_JCalls_cloned(&logger_conv);
24212         }
24213         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
24214 }
24215
24216 uint64_tArray  __attribute__((export_name("TS_ChannelMonitor_transactions_confirmed"))) TS_ChannelMonitor_transactions_confirmed(uint64_t this_arg, int8_tArray header, uint64_tArray txdata, int32_t height, uint64_t broadcaster, uint64_t fee_estimator, uint64_t logger) {
24217         LDKChannelMonitor this_arg_conv;
24218         this_arg_conv.inner = untag_ptr(this_arg);
24219         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24221         this_arg_conv.is_owned = false;
24222         unsigned char header_arr[80];
24223         CHECK(header->arr_len == 80);
24224         memcpy(header_arr, header->elems, 80); FREE(header);
24225         unsigned char (*header_ref)[80] = &header_arr;
24226         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
24227         txdata_constr.datalen = txdata->arr_len;
24228         if (txdata_constr.datalen > 0)
24229                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
24230         else
24231                 txdata_constr.data = NULL;
24232         uint64_t* txdata_vals = txdata->elems;
24233         for (size_t c = 0; c < txdata_constr.datalen; c++) {
24234                 uint64_t txdata_conv_28 = txdata_vals[c];
24235                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
24236                 CHECK_ACCESS(txdata_conv_28_ptr);
24237                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
24238                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
24239                 txdata_constr.data[c] = txdata_conv_28_conv;
24240         }
24241         FREE(txdata);
24242         void* broadcaster_ptr = untag_ptr(broadcaster);
24243         CHECK_ACCESS(broadcaster_ptr);
24244         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24245         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24246                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24247                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24248         }
24249         void* fee_estimator_ptr = untag_ptr(fee_estimator);
24250         CHECK_ACCESS(fee_estimator_ptr);
24251         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24252         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24253                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24254                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24255         }
24256         void* logger_ptr = untag_ptr(logger);
24257         CHECK_ACCESS(logger_ptr);
24258         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24259         if (logger_conv.free == LDKLogger_JCalls_free) {
24260                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24261                 LDKLogger_JCalls_cloned(&logger_conv);
24262         }
24263         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);
24264         uint64_tArray ret_arr = NULL;
24265         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
24266         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
24267         for (size_t n = 0; n < ret_var.datalen; n++) {
24268                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24269                 *ret_conv_39_conv = ret_var.data[n];
24270                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
24271         }
24272         
24273         FREE(ret_var.data);
24274         return ret_arr;
24275 }
24276
24277 void  __attribute__((export_name("TS_ChannelMonitor_transaction_unconfirmed"))) TS_ChannelMonitor_transaction_unconfirmed(uint64_t this_arg, int8_tArray txid, uint64_t broadcaster, uint64_t fee_estimator, uint64_t logger) {
24278         LDKChannelMonitor this_arg_conv;
24279         this_arg_conv.inner = untag_ptr(this_arg);
24280         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24282         this_arg_conv.is_owned = false;
24283         unsigned char txid_arr[32];
24284         CHECK(txid->arr_len == 32);
24285         memcpy(txid_arr, txid->elems, 32); FREE(txid);
24286         unsigned char (*txid_ref)[32] = &txid_arr;
24287         void* broadcaster_ptr = untag_ptr(broadcaster);
24288         CHECK_ACCESS(broadcaster_ptr);
24289         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24290         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24291                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24292                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24293         }
24294         void* fee_estimator_ptr = untag_ptr(fee_estimator);
24295         CHECK_ACCESS(fee_estimator_ptr);
24296         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24297         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24298                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24299                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24300         }
24301         void* logger_ptr = untag_ptr(logger);
24302         CHECK_ACCESS(logger_ptr);
24303         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24304         if (logger_conv.free == LDKLogger_JCalls_free) {
24305                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24306                 LDKLogger_JCalls_cloned(&logger_conv);
24307         }
24308         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
24309 }
24310
24311 uint64_tArray  __attribute__((export_name("TS_ChannelMonitor_best_block_updated"))) TS_ChannelMonitor_best_block_updated(uint64_t this_arg, int8_tArray header, int32_t height, uint64_t broadcaster, uint64_t fee_estimator, uint64_t logger) {
24312         LDKChannelMonitor this_arg_conv;
24313         this_arg_conv.inner = untag_ptr(this_arg);
24314         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24316         this_arg_conv.is_owned = false;
24317         unsigned char header_arr[80];
24318         CHECK(header->arr_len == 80);
24319         memcpy(header_arr, header->elems, 80); FREE(header);
24320         unsigned char (*header_ref)[80] = &header_arr;
24321         void* broadcaster_ptr = untag_ptr(broadcaster);
24322         CHECK_ACCESS(broadcaster_ptr);
24323         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24324         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24325                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24326                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24327         }
24328         void* fee_estimator_ptr = untag_ptr(fee_estimator);
24329         CHECK_ACCESS(fee_estimator_ptr);
24330         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24331         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24332                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24333                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24334         }
24335         void* logger_ptr = untag_ptr(logger);
24336         CHECK_ACCESS(logger_ptr);
24337         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24338         if (logger_conv.free == LDKLogger_JCalls_free) {
24339                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24340                 LDKLogger_JCalls_cloned(&logger_conv);
24341         }
24342         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
24343         uint64_tArray ret_arr = NULL;
24344         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
24345         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
24346         for (size_t n = 0; n < ret_var.datalen; n++) {
24347                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24348                 *ret_conv_39_conv = ret_var.data[n];
24349                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
24350         }
24351         
24352         FREE(ret_var.data);
24353         return ret_arr;
24354 }
24355
24356 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint64_t this_arg) {
24357         LDKChannelMonitor this_arg_conv;
24358         this_arg_conv.inner = untag_ptr(this_arg);
24359         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24361         this_arg_conv.is_owned = false;
24362         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
24363         ptrArray ret_arr = NULL;
24364         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
24365         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
24366         for (size_t m = 0; m < ret_var.datalen; m++) {
24367                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
24368                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
24369                 ret_arr_ptr[m] = ret_conv_12_arr;
24370         }
24371         
24372         FREE(ret_var.data);
24373         return ret_arr;
24374 }
24375
24376 uint64_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint64_t this_arg) {
24377         LDKChannelMonitor this_arg_conv;
24378         this_arg_conv.inner = untag_ptr(this_arg);
24379         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24381         this_arg_conv.is_owned = false;
24382         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
24383         uint64_t ret_ref = 0;
24384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24385         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24386         return ret_ref;
24387 }
24388
24389 uint64_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint64_t this_arg) {
24390         LDKChannelMonitor this_arg_conv;
24391         this_arg_conv.inner = untag_ptr(this_arg);
24392         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24394         this_arg_conv.is_owned = false;
24395         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
24396         uint64_tArray ret_arr = NULL;
24397         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
24398         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
24399         for (size_t j = 0; j < ret_var.datalen; j++) {
24400                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
24401                 *ret_conv_9_copy = ret_var.data[j];
24402                 uint64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
24403                 ret_arr_ptr[j] = ret_conv_9_ref;
24404         }
24405         
24406         FREE(ret_var.data);
24407         return ret_arr;
24408 }
24409
24410 uint64_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint64_t arg) {
24411         LDKu8slice ser_ref;
24412         ser_ref.datalen = ser->arr_len;
24413         ser_ref.data = ser->elems;
24414         void* arg_ptr = untag_ptr(arg);
24415         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
24416         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
24417         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
24418         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
24419         FREE(ser);
24420         return tag_ptr(ret_conv, true);
24421 }
24422
24423 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint64_t this_obj) {
24424         LDKOutPoint this_obj_conv;
24425         this_obj_conv.inner = untag_ptr(this_obj);
24426         this_obj_conv.is_owned = ptr_is_owned(this_obj);
24427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24428         OutPoint_free(this_obj_conv);
24429 }
24430
24431 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint64_t this_ptr) {
24432         LDKOutPoint this_ptr_conv;
24433         this_ptr_conv.inner = untag_ptr(this_ptr);
24434         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24436         this_ptr_conv.is_owned = false;
24437         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24438         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
24439         return ret_arr;
24440 }
24441
24442 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint64_t this_ptr, int8_tArray val) {
24443         LDKOutPoint this_ptr_conv;
24444         this_ptr_conv.inner = untag_ptr(this_ptr);
24445         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24447         this_ptr_conv.is_owned = false;
24448         LDKThirtyTwoBytes val_ref;
24449         CHECK(val->arr_len == 32);
24450         memcpy(val_ref.data, val->elems, 32); FREE(val);
24451         OutPoint_set_txid(&this_ptr_conv, val_ref);
24452 }
24453
24454 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint64_t this_ptr) {
24455         LDKOutPoint this_ptr_conv;
24456         this_ptr_conv.inner = untag_ptr(this_ptr);
24457         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24459         this_ptr_conv.is_owned = false;
24460         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
24461         return ret_conv;
24462 }
24463
24464 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint64_t this_ptr, int16_t val) {
24465         LDKOutPoint this_ptr_conv;
24466         this_ptr_conv.inner = untag_ptr(this_ptr);
24467         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24469         this_ptr_conv.is_owned = false;
24470         OutPoint_set_index(&this_ptr_conv, val);
24471 }
24472
24473 uint64_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
24474         LDKThirtyTwoBytes txid_arg_ref;
24475         CHECK(txid_arg->arr_len == 32);
24476         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
24477         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
24478         uint64_t ret_ref = 0;
24479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24480         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24481         return ret_ref;
24482 }
24483
24484 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
24485         LDKOutPoint ret_var = OutPoint_clone(arg);
24486         uint64_t ret_ref = 0;
24487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24488         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24489         return ret_ref;
24490 }
24491 int64_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint64_t arg) {
24492         LDKOutPoint arg_conv;
24493         arg_conv.inner = untag_ptr(arg);
24494         arg_conv.is_owned = ptr_is_owned(arg);
24495         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24496         arg_conv.is_owned = false;
24497         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
24498         return ret_conv;
24499 }
24500
24501 uint64_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint64_t orig) {
24502         LDKOutPoint orig_conv;
24503         orig_conv.inner = untag_ptr(orig);
24504         orig_conv.is_owned = ptr_is_owned(orig);
24505         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24506         orig_conv.is_owned = false;
24507         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
24508         uint64_t ret_ref = 0;
24509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24510         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24511         return ret_ref;
24512 }
24513
24514 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint64_t a, uint64_t b) {
24515         LDKOutPoint a_conv;
24516         a_conv.inner = untag_ptr(a);
24517         a_conv.is_owned = ptr_is_owned(a);
24518         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24519         a_conv.is_owned = false;
24520         LDKOutPoint b_conv;
24521         b_conv.inner = untag_ptr(b);
24522         b_conv.is_owned = ptr_is_owned(b);
24523         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
24524         b_conv.is_owned = false;
24525         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
24526         return ret_conv;
24527 }
24528
24529 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint64_t o) {
24530         LDKOutPoint o_conv;
24531         o_conv.inner = untag_ptr(o);
24532         o_conv.is_owned = ptr_is_owned(o);
24533         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24534         o_conv.is_owned = false;
24535         int64_t ret_conv = OutPoint_hash(&o_conv);
24536         return ret_conv;
24537 }
24538
24539 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint64_t this_arg) {
24540         LDKOutPoint this_arg_conv;
24541         this_arg_conv.inner = untag_ptr(this_arg);
24542         this_arg_conv.is_owned = ptr_is_owned(this_arg);
24543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24544         this_arg_conv.is_owned = false;
24545         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24546         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
24547         return ret_arr;
24548 }
24549
24550 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint64_t obj) {
24551         LDKOutPoint obj_conv;
24552         obj_conv.inner = untag_ptr(obj);
24553         obj_conv.is_owned = ptr_is_owned(obj);
24554         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24555         obj_conv.is_owned = false;
24556         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
24557         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24558         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24559         CVec_u8Z_free(ret_var);
24560         return ret_arr;
24561 }
24562
24563 uint64_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
24564         LDKu8slice ser_ref;
24565         ser_ref.datalen = ser->arr_len;
24566         ser_ref.data = ser->elems;
24567         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
24568         *ret_conv = OutPoint_read(ser_ref);
24569         FREE(ser);
24570         return tag_ptr(ret_conv, true);
24571 }
24572
24573 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint64_t this_obj) {
24574         LDKDelayedPaymentOutputDescriptor this_obj_conv;
24575         this_obj_conv.inner = untag_ptr(this_obj);
24576         this_obj_conv.is_owned = ptr_is_owned(this_obj);
24577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24578         DelayedPaymentOutputDescriptor_free(this_obj_conv);
24579 }
24580
24581 uint64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint64_t this_ptr) {
24582         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24583         this_ptr_conv.inner = untag_ptr(this_ptr);
24584         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24586         this_ptr_conv.is_owned = false;
24587         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
24588         uint64_t ret_ref = 0;
24589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24590         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24591         return ret_ref;
24592 }
24593
24594 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint64_t this_ptr, uint64_t val) {
24595         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24596         this_ptr_conv.inner = untag_ptr(this_ptr);
24597         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24599         this_ptr_conv.is_owned = false;
24600         LDKOutPoint val_conv;
24601         val_conv.inner = untag_ptr(val);
24602         val_conv.is_owned = ptr_is_owned(val);
24603         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24604         val_conv = OutPoint_clone(&val_conv);
24605         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
24606 }
24607
24608 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint64_t this_ptr) {
24609         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24610         this_ptr_conv.inner = untag_ptr(this_ptr);
24611         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24613         this_ptr_conv.is_owned = false;
24614         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24615         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
24616         return ret_arr;
24617 }
24618
24619 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint64_t this_ptr, int8_tArray val) {
24620         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24621         this_ptr_conv.inner = untag_ptr(this_ptr);
24622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24624         this_ptr_conv.is_owned = false;
24625         LDKPublicKey val_ref;
24626         CHECK(val->arr_len == 33);
24627         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24628         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
24629 }
24630
24631 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint64_t this_ptr) {
24632         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24633         this_ptr_conv.inner = untag_ptr(this_ptr);
24634         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24636         this_ptr_conv.is_owned = false;
24637         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
24638         return ret_conv;
24639 }
24640
24641 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint64_t this_ptr, int16_t val) {
24642         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24643         this_ptr_conv.inner = untag_ptr(this_ptr);
24644         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24646         this_ptr_conv.is_owned = false;
24647         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
24648 }
24649
24650 uint64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_output"))) TS_DelayedPaymentOutputDescriptor_get_output(uint64_t this_ptr) {
24651         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24652         this_ptr_conv.inner = untag_ptr(this_ptr);
24653         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24655         this_ptr_conv.is_owned = false;
24656         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
24657         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
24658         return tag_ptr(ret_ref, true);
24659 }
24660
24661 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint64_t this_ptr, uint64_t val) {
24662         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24663         this_ptr_conv.inner = untag_ptr(this_ptr);
24664         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24666         this_ptr_conv.is_owned = false;
24667         void* val_ptr = untag_ptr(val);
24668         CHECK_ACCESS(val_ptr);
24669         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
24670         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
24671         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
24672 }
24673
24674 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint64_t this_ptr) {
24675         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24676         this_ptr_conv.inner = untag_ptr(this_ptr);
24677         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24679         this_ptr_conv.is_owned = false;
24680         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24681         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
24682         return ret_arr;
24683 }
24684
24685 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint64_t this_ptr, int8_tArray val) {
24686         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24687         this_ptr_conv.inner = untag_ptr(this_ptr);
24688         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24690         this_ptr_conv.is_owned = false;
24691         LDKPublicKey val_ref;
24692         CHECK(val->arr_len == 33);
24693         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24694         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
24695 }
24696
24697 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint64_t this_ptr) {
24698         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24699         this_ptr_conv.inner = untag_ptr(this_ptr);
24700         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24702         this_ptr_conv.is_owned = false;
24703         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24704         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
24705         return ret_arr;
24706 }
24707
24708 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint64_t this_ptr, int8_tArray val) {
24709         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24710         this_ptr_conv.inner = untag_ptr(this_ptr);
24711         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24713         this_ptr_conv.is_owned = false;
24714         LDKThirtyTwoBytes val_ref;
24715         CHECK(val->arr_len == 32);
24716         memcpy(val_ref.data, val->elems, 32); FREE(val);
24717         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
24718 }
24719
24720 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint64_t this_ptr) {
24721         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24722         this_ptr_conv.inner = untag_ptr(this_ptr);
24723         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24725         this_ptr_conv.is_owned = false;
24726         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
24727         return ret_conv;
24728 }
24729
24730 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint64_t this_ptr, int64_t val) {
24731         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24732         this_ptr_conv.inner = untag_ptr(this_ptr);
24733         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24735         this_ptr_conv.is_owned = false;
24736         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
24737 }
24738
24739 uint64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_new"))) TS_DelayedPaymentOutputDescriptor_new(uint64_t outpoint_arg, int8_tArray per_commitment_point_arg, int16_t to_self_delay_arg, uint64_t output_arg, int8_tArray revocation_pubkey_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
24740         LDKOutPoint outpoint_arg_conv;
24741         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
24742         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
24743         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
24744         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
24745         LDKPublicKey per_commitment_point_arg_ref;
24746         CHECK(per_commitment_point_arg->arr_len == 33);
24747         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
24748         void* output_arg_ptr = untag_ptr(output_arg);
24749         CHECK_ACCESS(output_arg_ptr);
24750         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
24751         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
24752         LDKPublicKey revocation_pubkey_arg_ref;
24753         CHECK(revocation_pubkey_arg->arr_len == 33);
24754         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
24755         LDKThirtyTwoBytes channel_keys_id_arg_ref;
24756         CHECK(channel_keys_id_arg->arr_len == 32);
24757         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
24758         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);
24759         uint64_t ret_ref = 0;
24760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24762         return ret_ref;
24763 }
24764
24765 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
24766         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
24767         uint64_t ret_ref = 0;
24768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24769         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24770         return ret_ref;
24771 }
24772 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint64_t arg) {
24773         LDKDelayedPaymentOutputDescriptor arg_conv;
24774         arg_conv.inner = untag_ptr(arg);
24775         arg_conv.is_owned = ptr_is_owned(arg);
24776         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24777         arg_conv.is_owned = false;
24778         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
24779         return ret_conv;
24780 }
24781
24782 uint64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint64_t orig) {
24783         LDKDelayedPaymentOutputDescriptor orig_conv;
24784         orig_conv.inner = untag_ptr(orig);
24785         orig_conv.is_owned = ptr_is_owned(orig);
24786         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24787         orig_conv.is_owned = false;
24788         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
24789         uint64_t ret_ref = 0;
24790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24791         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24792         return ret_ref;
24793 }
24794
24795 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint64_t obj) {
24796         LDKDelayedPaymentOutputDescriptor obj_conv;
24797         obj_conv.inner = untag_ptr(obj);
24798         obj_conv.is_owned = ptr_is_owned(obj);
24799         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24800         obj_conv.is_owned = false;
24801         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
24802         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24803         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24804         CVec_u8Z_free(ret_var);
24805         return ret_arr;
24806 }
24807
24808 uint64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
24809         LDKu8slice ser_ref;
24810         ser_ref.datalen = ser->arr_len;
24811         ser_ref.data = ser->elems;
24812         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
24813         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
24814         FREE(ser);
24815         return tag_ptr(ret_conv, true);
24816 }
24817
24818 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint64_t this_obj) {
24819         LDKStaticPaymentOutputDescriptor this_obj_conv;
24820         this_obj_conv.inner = untag_ptr(this_obj);
24821         this_obj_conv.is_owned = ptr_is_owned(this_obj);
24822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24823         StaticPaymentOutputDescriptor_free(this_obj_conv);
24824 }
24825
24826 uint64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint64_t this_ptr) {
24827         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24828         this_ptr_conv.inner = untag_ptr(this_ptr);
24829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24831         this_ptr_conv.is_owned = false;
24832         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
24833         uint64_t ret_ref = 0;
24834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24835         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24836         return ret_ref;
24837 }
24838
24839 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint64_t this_ptr, uint64_t val) {
24840         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24841         this_ptr_conv.inner = untag_ptr(this_ptr);
24842         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24844         this_ptr_conv.is_owned = false;
24845         LDKOutPoint val_conv;
24846         val_conv.inner = untag_ptr(val);
24847         val_conv.is_owned = ptr_is_owned(val);
24848         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24849         val_conv = OutPoint_clone(&val_conv);
24850         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
24851 }
24852
24853 uint64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_output"))) TS_StaticPaymentOutputDescriptor_get_output(uint64_t this_ptr) {
24854         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24855         this_ptr_conv.inner = untag_ptr(this_ptr);
24856         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24858         this_ptr_conv.is_owned = false;
24859         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
24860         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
24861         return tag_ptr(ret_ref, true);
24862 }
24863
24864 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint64_t this_ptr, uint64_t val) {
24865         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24866         this_ptr_conv.inner = untag_ptr(this_ptr);
24867         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24869         this_ptr_conv.is_owned = false;
24870         void* val_ptr = untag_ptr(val);
24871         CHECK_ACCESS(val_ptr);
24872         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
24873         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
24874         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
24875 }
24876
24877 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint64_t this_ptr) {
24878         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24879         this_ptr_conv.inner = untag_ptr(this_ptr);
24880         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24882         this_ptr_conv.is_owned = false;
24883         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24884         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
24885         return ret_arr;
24886 }
24887
24888 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint64_t this_ptr, int8_tArray val) {
24889         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24890         this_ptr_conv.inner = untag_ptr(this_ptr);
24891         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24893         this_ptr_conv.is_owned = false;
24894         LDKThirtyTwoBytes val_ref;
24895         CHECK(val->arr_len == 32);
24896         memcpy(val_ref.data, val->elems, 32); FREE(val);
24897         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
24898 }
24899
24900 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint64_t this_ptr) {
24901         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24902         this_ptr_conv.inner = untag_ptr(this_ptr);
24903         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24905         this_ptr_conv.is_owned = false;
24906         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
24907         return ret_conv;
24908 }
24909
24910 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint64_t this_ptr, int64_t val) {
24911         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24912         this_ptr_conv.inner = untag_ptr(this_ptr);
24913         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
24914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24915         this_ptr_conv.is_owned = false;
24916         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
24917 }
24918
24919 uint64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_new"))) TS_StaticPaymentOutputDescriptor_new(uint64_t outpoint_arg, uint64_t output_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
24920         LDKOutPoint outpoint_arg_conv;
24921         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
24922         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
24923         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
24924         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
24925         void* output_arg_ptr = untag_ptr(output_arg);
24926         CHECK_ACCESS(output_arg_ptr);
24927         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
24928         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
24929         LDKThirtyTwoBytes channel_keys_id_arg_ref;
24930         CHECK(channel_keys_id_arg->arr_len == 32);
24931         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
24932         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
24933         uint64_t ret_ref = 0;
24934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24935         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24936         return ret_ref;
24937 }
24938
24939 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
24940         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
24941         uint64_t ret_ref = 0;
24942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24943         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24944         return ret_ref;
24945 }
24946 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint64_t arg) {
24947         LDKStaticPaymentOutputDescriptor arg_conv;
24948         arg_conv.inner = untag_ptr(arg);
24949         arg_conv.is_owned = ptr_is_owned(arg);
24950         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24951         arg_conv.is_owned = false;
24952         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
24953         return ret_conv;
24954 }
24955
24956 uint64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint64_t orig) {
24957         LDKStaticPaymentOutputDescriptor orig_conv;
24958         orig_conv.inner = untag_ptr(orig);
24959         orig_conv.is_owned = ptr_is_owned(orig);
24960         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24961         orig_conv.is_owned = false;
24962         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
24963         uint64_t ret_ref = 0;
24964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24965         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
24966         return ret_ref;
24967 }
24968
24969 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint64_t obj) {
24970         LDKStaticPaymentOutputDescriptor obj_conv;
24971         obj_conv.inner = untag_ptr(obj);
24972         obj_conv.is_owned = ptr_is_owned(obj);
24973         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24974         obj_conv.is_owned = false;
24975         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
24976         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24977         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24978         CVec_u8Z_free(ret_var);
24979         return ret_arr;
24980 }
24981
24982 uint64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
24983         LDKu8slice ser_ref;
24984         ser_ref.datalen = ser->arr_len;
24985         ser_ref.data = ser->elems;
24986         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
24987         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
24988         FREE(ser);
24989         return tag_ptr(ret_conv, true);
24990 }
24991
24992 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint64_t this_ptr) {
24993         if (!ptr_is_owned(this_ptr)) return;
24994         void* this_ptr_ptr = untag_ptr(this_ptr);
24995         CHECK_ACCESS(this_ptr_ptr);
24996         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
24997         FREE(untag_ptr(this_ptr));
24998         SpendableOutputDescriptor_free(this_ptr_conv);
24999 }
25000
25001 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
25002         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25003         *ret_copy = SpendableOutputDescriptor_clone(arg);
25004         uint64_t ret_ref = tag_ptr(ret_copy, true);
25005         return ret_ref;
25006 }
25007 int64_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint64_t arg) {
25008         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(arg);
25009         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
25010         return ret_conv;
25011 }
25012
25013 uint64_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint64_t orig) {
25014         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)untag_ptr(orig);
25015         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25016         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
25017         uint64_t ret_ref = tag_ptr(ret_copy, true);
25018         return ret_ref;
25019 }
25020
25021 uint64_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint64_t outpoint, uint64_t output) {
25022         LDKOutPoint outpoint_conv;
25023         outpoint_conv.inner = untag_ptr(outpoint);
25024         outpoint_conv.is_owned = ptr_is_owned(outpoint);
25025         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
25026         outpoint_conv = OutPoint_clone(&outpoint_conv);
25027         void* output_ptr = untag_ptr(output);
25028         CHECK_ACCESS(output_ptr);
25029         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
25030         output_conv = TxOut_clone((LDKTxOut*)untag_ptr(output));
25031         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25032         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
25033         uint64_t ret_ref = tag_ptr(ret_copy, true);
25034         return ret_ref;
25035 }
25036
25037 uint64_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint64_t a) {
25038         LDKDelayedPaymentOutputDescriptor a_conv;
25039         a_conv.inner = untag_ptr(a);
25040         a_conv.is_owned = ptr_is_owned(a);
25041         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25042         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
25043         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25044         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
25045         uint64_t ret_ref = tag_ptr(ret_copy, true);
25046         return ret_ref;
25047 }
25048
25049 uint64_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint64_t a) {
25050         LDKStaticPaymentOutputDescriptor a_conv;
25051         a_conv.inner = untag_ptr(a);
25052         a_conv.is_owned = ptr_is_owned(a);
25053         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25054         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
25055         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25056         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
25057         uint64_t ret_ref = tag_ptr(ret_copy, true);
25058         return ret_ref;
25059 }
25060
25061 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint64_t obj) {
25062         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)untag_ptr(obj);
25063         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
25064         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25065         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25066         CVec_u8Z_free(ret_var);
25067         return ret_arr;
25068 }
25069
25070 uint64_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
25071         LDKu8slice ser_ref;
25072         ser_ref.datalen = ser->arr_len;
25073         ser_ref.data = ser->elems;
25074         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
25075         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
25076         FREE(ser);
25077         return tag_ptr(ret_conv, true);
25078 }
25079
25080 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint64_t this_ptr) {
25081         if (!ptr_is_owned(this_ptr)) return;
25082         void* this_ptr_ptr = untag_ptr(this_ptr);
25083         CHECK_ACCESS(this_ptr_ptr);
25084         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
25085         FREE(untag_ptr(this_ptr));
25086         BaseSign_free(this_ptr_conv);
25087 }
25088
25089 static inline uint64_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
25090         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25091         *ret_ret = Sign_clone(arg);
25092         return tag_ptr(ret_ret, true);
25093 }
25094 int64_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint64_t arg) {
25095         void* arg_ptr = untag_ptr(arg);
25096         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
25097         LDKSign* arg_conv = (LDKSign*)arg_ptr;
25098         int64_t ret_conv = Sign_clone_ptr(arg_conv);
25099         return ret_conv;
25100 }
25101
25102 uint64_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint64_t orig) {
25103         void* orig_ptr = untag_ptr(orig);
25104         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
25105         LDKSign* orig_conv = (LDKSign*)orig_ptr;
25106         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25107         *ret_ret = Sign_clone(orig_conv);
25108         return tag_ptr(ret_ret, true);
25109 }
25110
25111 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint64_t this_ptr) {
25112         if (!ptr_is_owned(this_ptr)) return;
25113         void* this_ptr_ptr = untag_ptr(this_ptr);
25114         CHECK_ACCESS(this_ptr_ptr);
25115         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
25116         FREE(untag_ptr(this_ptr));
25117         Sign_free(this_ptr_conv);
25118 }
25119
25120 uint32_t  __attribute__((export_name("TS_Recipient_clone"))) TS_Recipient_clone(uint64_t orig) {
25121         LDKRecipient* orig_conv = (LDKRecipient*)untag_ptr(orig);
25122         uint32_t ret_conv = LDKRecipient_to_js(Recipient_clone(orig_conv));
25123         return ret_conv;
25124 }
25125
25126 uint32_t  __attribute__((export_name("TS_Recipient_node"))) TS_Recipient_node() {
25127         uint32_t ret_conv = LDKRecipient_to_js(Recipient_node());
25128         return ret_conv;
25129 }
25130
25131 uint32_t  __attribute__((export_name("TS_Recipient_phantom_node"))) TS_Recipient_phantom_node() {
25132         uint32_t ret_conv = LDKRecipient_to_js(Recipient_phantom_node());
25133         return ret_conv;
25134 }
25135
25136 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint64_t this_ptr) {
25137         if (!ptr_is_owned(this_ptr)) return;
25138         void* this_ptr_ptr = untag_ptr(this_ptr);
25139         CHECK_ACCESS(this_ptr_ptr);
25140         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
25141         FREE(untag_ptr(this_ptr));
25142         KeysInterface_free(this_ptr_conv);
25143 }
25144
25145 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint64_t this_obj) {
25146         LDKInMemorySigner this_obj_conv;
25147         this_obj_conv.inner = untag_ptr(this_obj);
25148         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25150         InMemorySigner_free(this_obj_conv);
25151 }
25152
25153 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint64_t this_ptr) {
25154         LDKInMemorySigner this_ptr_conv;
25155         this_ptr_conv.inner = untag_ptr(this_ptr);
25156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25158         this_ptr_conv.is_owned = false;
25159         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25160         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
25161         return ret_arr;
25162 }
25163
25164 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint64_t this_ptr, int8_tArray val) {
25165         LDKInMemorySigner this_ptr_conv;
25166         this_ptr_conv.inner = untag_ptr(this_ptr);
25167         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25169         this_ptr_conv.is_owned = false;
25170         LDKSecretKey val_ref;
25171         CHECK(val->arr_len == 32);
25172         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25173         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
25174 }
25175
25176 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint64_t this_ptr) {
25177         LDKInMemorySigner this_ptr_conv;
25178         this_ptr_conv.inner = untag_ptr(this_ptr);
25179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25181         this_ptr_conv.is_owned = false;
25182         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25183         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
25184         return ret_arr;
25185 }
25186
25187 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint64_t this_ptr, int8_tArray val) {
25188         LDKInMemorySigner this_ptr_conv;
25189         this_ptr_conv.inner = untag_ptr(this_ptr);
25190         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25192         this_ptr_conv.is_owned = false;
25193         LDKSecretKey val_ref;
25194         CHECK(val->arr_len == 32);
25195         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25196         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
25197 }
25198
25199 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint64_t this_ptr) {
25200         LDKInMemorySigner this_ptr_conv;
25201         this_ptr_conv.inner = untag_ptr(this_ptr);
25202         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25204         this_ptr_conv.is_owned = false;
25205         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25206         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
25207         return ret_arr;
25208 }
25209
25210 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint64_t this_ptr, int8_tArray val) {
25211         LDKInMemorySigner this_ptr_conv;
25212         this_ptr_conv.inner = untag_ptr(this_ptr);
25213         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25215         this_ptr_conv.is_owned = false;
25216         LDKSecretKey val_ref;
25217         CHECK(val->arr_len == 32);
25218         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25219         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
25220 }
25221
25222 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint64_t this_ptr) {
25223         LDKInMemorySigner this_ptr_conv;
25224         this_ptr_conv.inner = untag_ptr(this_ptr);
25225         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25227         this_ptr_conv.is_owned = false;
25228         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25229         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
25230         return ret_arr;
25231 }
25232
25233 void  __attribute__((export_name("TS_InMemorySigner_set_delayed_payment_base_key"))) TS_InMemorySigner_set_delayed_payment_base_key(uint64_t this_ptr, int8_tArray val) {
25234         LDKInMemorySigner this_ptr_conv;
25235         this_ptr_conv.inner = untag_ptr(this_ptr);
25236         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25238         this_ptr_conv.is_owned = false;
25239         LDKSecretKey val_ref;
25240         CHECK(val->arr_len == 32);
25241         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25242         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
25243 }
25244
25245 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint64_t this_ptr) {
25246         LDKInMemorySigner this_ptr_conv;
25247         this_ptr_conv.inner = untag_ptr(this_ptr);
25248         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25250         this_ptr_conv.is_owned = false;
25251         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25252         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
25253         return ret_arr;
25254 }
25255
25256 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint64_t this_ptr, int8_tArray val) {
25257         LDKInMemorySigner this_ptr_conv;
25258         this_ptr_conv.inner = untag_ptr(this_ptr);
25259         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25261         this_ptr_conv.is_owned = false;
25262         LDKSecretKey val_ref;
25263         CHECK(val->arr_len == 32);
25264         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25265         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
25266 }
25267
25268 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint64_t this_ptr) {
25269         LDKInMemorySigner this_ptr_conv;
25270         this_ptr_conv.inner = untag_ptr(this_ptr);
25271         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25273         this_ptr_conv.is_owned = false;
25274         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25275         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
25276         return ret_arr;
25277 }
25278
25279 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint64_t this_ptr, int8_tArray val) {
25280         LDKInMemorySigner this_ptr_conv;
25281         this_ptr_conv.inner = untag_ptr(this_ptr);
25282         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25284         this_ptr_conv.is_owned = false;
25285         LDKThirtyTwoBytes val_ref;
25286         CHECK(val->arr_len == 32);
25287         memcpy(val_ref.data, val->elems, 32); FREE(val);
25288         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
25289 }
25290
25291 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
25292         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
25293         uint64_t ret_ref = 0;
25294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25295         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25296         return ret_ref;
25297 }
25298 int64_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint64_t arg) {
25299         LDKInMemorySigner arg_conv;
25300         arg_conv.inner = untag_ptr(arg);
25301         arg_conv.is_owned = ptr_is_owned(arg);
25302         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25303         arg_conv.is_owned = false;
25304         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
25305         return ret_conv;
25306 }
25307
25308 uint64_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint64_t orig) {
25309         LDKInMemorySigner orig_conv;
25310         orig_conv.inner = untag_ptr(orig);
25311         orig_conv.is_owned = ptr_is_owned(orig);
25312         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25313         orig_conv.is_owned = false;
25314         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
25315         uint64_t ret_ref = 0;
25316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25317         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25318         return ret_ref;
25319 }
25320
25321 uint64_t  __attribute__((export_name("TS_InMemorySigner_new"))) TS_InMemorySigner_new(int8_tArray node_secret, 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) {
25322         LDKSecretKey node_secret_ref;
25323         CHECK(node_secret->arr_len == 32);
25324         memcpy(node_secret_ref.bytes, node_secret->elems, 32); FREE(node_secret);
25325         LDKSecretKey funding_key_ref;
25326         CHECK(funding_key->arr_len == 32);
25327         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
25328         LDKSecretKey revocation_base_key_ref;
25329         CHECK(revocation_base_key->arr_len == 32);
25330         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
25331         LDKSecretKey payment_key_ref;
25332         CHECK(payment_key->arr_len == 32);
25333         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
25334         LDKSecretKey delayed_payment_base_key_ref;
25335         CHECK(delayed_payment_base_key->arr_len == 32);
25336         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
25337         LDKSecretKey htlc_base_key_ref;
25338         CHECK(htlc_base_key->arr_len == 32);
25339         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
25340         LDKThirtyTwoBytes commitment_seed_ref;
25341         CHECK(commitment_seed->arr_len == 32);
25342         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
25343         LDKThirtyTwoBytes channel_keys_id_ref;
25344         CHECK(channel_keys_id->arr_len == 32);
25345         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
25346         LDKInMemorySigner ret_var = InMemorySigner_new(node_secret_ref, 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);
25347         uint64_t ret_ref = 0;
25348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25349         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25350         return ret_ref;
25351 }
25352
25353 uint64_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint64_t this_arg) {
25354         LDKInMemorySigner this_arg_conv;
25355         this_arg_conv.inner = untag_ptr(this_arg);
25356         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25358         this_arg_conv.is_owned = false;
25359         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
25360         uint64_t ret_ref = 0;
25361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25362         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25363         return ret_ref;
25364 }
25365
25366 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint64_t this_arg) {
25367         LDKInMemorySigner this_arg_conv;
25368         this_arg_conv.inner = untag_ptr(this_arg);
25369         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25371         this_arg_conv.is_owned = false;
25372         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
25373         return ret_conv;
25374 }
25375
25376 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint64_t this_arg) {
25377         LDKInMemorySigner this_arg_conv;
25378         this_arg_conv.inner = untag_ptr(this_arg);
25379         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25381         this_arg_conv.is_owned = false;
25382         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
25383         return ret_conv;
25384 }
25385
25386 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint64_t this_arg) {
25387         LDKInMemorySigner this_arg_conv;
25388         this_arg_conv.inner = untag_ptr(this_arg);
25389         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25391         this_arg_conv.is_owned = false;
25392         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
25393         return ret_conv;
25394 }
25395
25396 uint64_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint64_t this_arg) {
25397         LDKInMemorySigner this_arg_conv;
25398         this_arg_conv.inner = untag_ptr(this_arg);
25399         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25401         this_arg_conv.is_owned = false;
25402         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
25403         uint64_t ret_ref = 0;
25404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25405         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25406         return ret_ref;
25407 }
25408
25409 uint64_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint64_t this_arg) {
25410         LDKInMemorySigner this_arg_conv;
25411         this_arg_conv.inner = untag_ptr(this_arg);
25412         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25414         this_arg_conv.is_owned = false;
25415         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
25416         uint64_t ret_ref = 0;
25417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25418         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25419         return ret_ref;
25420 }
25421
25422 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint64_t this_arg) {
25423         LDKInMemorySigner this_arg_conv;
25424         this_arg_conv.inner = untag_ptr(this_arg);
25425         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25427         this_arg_conv.is_owned = false;
25428         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
25429         return ret_conv;
25430 }
25431
25432 uint64_t  __attribute__((export_name("TS_InMemorySigner_sign_counterparty_payment_input"))) TS_InMemorySigner_sign_counterparty_payment_input(uint64_t this_arg, int8_tArray spend_tx, uint32_t input_idx, uint64_t descriptor) {
25433         LDKInMemorySigner this_arg_conv;
25434         this_arg_conv.inner = untag_ptr(this_arg);
25435         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25437         this_arg_conv.is_owned = false;
25438         LDKTransaction spend_tx_ref;
25439         spend_tx_ref.datalen = spend_tx->arr_len;
25440         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
25441         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
25442         spend_tx_ref.data_is_owned = true;
25443         LDKStaticPaymentOutputDescriptor descriptor_conv;
25444         descriptor_conv.inner = untag_ptr(descriptor);
25445         descriptor_conv.is_owned = ptr_is_owned(descriptor);
25446         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
25447         descriptor_conv.is_owned = false;
25448         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
25449         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
25450         return tag_ptr(ret_conv, true);
25451 }
25452
25453 uint64_t  __attribute__((export_name("TS_InMemorySigner_sign_dynamic_p2wsh_input"))) TS_InMemorySigner_sign_dynamic_p2wsh_input(uint64_t this_arg, int8_tArray spend_tx, uint32_t input_idx, uint64_t descriptor) {
25454         LDKInMemorySigner this_arg_conv;
25455         this_arg_conv.inner = untag_ptr(this_arg);
25456         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25458         this_arg_conv.is_owned = false;
25459         LDKTransaction spend_tx_ref;
25460         spend_tx_ref.datalen = spend_tx->arr_len;
25461         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
25462         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
25463         spend_tx_ref.data_is_owned = true;
25464         LDKDelayedPaymentOutputDescriptor descriptor_conv;
25465         descriptor_conv.inner = untag_ptr(descriptor);
25466         descriptor_conv.is_owned = ptr_is_owned(descriptor);
25467         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
25468         descriptor_conv.is_owned = false;
25469         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
25470         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
25471         return tag_ptr(ret_conv, true);
25472 }
25473
25474 uint64_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint64_t this_arg) {
25475         LDKInMemorySigner this_arg_conv;
25476         this_arg_conv.inner = untag_ptr(this_arg);
25477         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25479         this_arg_conv.is_owned = false;
25480         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
25481         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
25482         return tag_ptr(ret_ret, true);
25483 }
25484
25485 uint64_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint64_t this_arg) {
25486         LDKInMemorySigner this_arg_conv;
25487         this_arg_conv.inner = untag_ptr(this_arg);
25488         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25490         this_arg_conv.is_owned = false;
25491         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25492         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
25493         return tag_ptr(ret_ret, true);
25494 }
25495
25496 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint64_t obj) {
25497         LDKInMemorySigner obj_conv;
25498         obj_conv.inner = untag_ptr(obj);
25499         obj_conv.is_owned = ptr_is_owned(obj);
25500         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25501         obj_conv.is_owned = false;
25502         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
25503         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25504         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25505         CVec_u8Z_free(ret_var);
25506         return ret_arr;
25507 }
25508
25509 uint64_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser, int8_tArray arg) {
25510         LDKu8slice ser_ref;
25511         ser_ref.datalen = ser->arr_len;
25512         ser_ref.data = ser->elems;
25513         LDKSecretKey arg_ref;
25514         CHECK(arg->arr_len == 32);
25515         memcpy(arg_ref.bytes, arg->elems, 32); FREE(arg);
25516         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
25517         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
25518         FREE(ser);
25519         return tag_ptr(ret_conv, true);
25520 }
25521
25522 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint64_t this_obj) {
25523         LDKKeysManager this_obj_conv;
25524         this_obj_conv.inner = untag_ptr(this_obj);
25525         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25527         KeysManager_free(this_obj_conv);
25528 }
25529
25530 uint64_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
25531         unsigned char seed_arr[32];
25532         CHECK(seed->arr_len == 32);
25533         memcpy(seed_arr, seed->elems, 32); FREE(seed);
25534         unsigned char (*seed_ref)[32] = &seed_arr;
25535         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
25536         uint64_t ret_ref = 0;
25537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25538         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25539         return ret_ref;
25540 }
25541
25542 uint64_t  __attribute__((export_name("TS_KeysManager_derive_channel_keys"))) TS_KeysManager_derive_channel_keys(uint64_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
25543         LDKKeysManager this_arg_conv;
25544         this_arg_conv.inner = untag_ptr(this_arg);
25545         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25547         this_arg_conv.is_owned = false;
25548         unsigned char params_arr[32];
25549         CHECK(params->arr_len == 32);
25550         memcpy(params_arr, params->elems, 32); FREE(params);
25551         unsigned char (*params_ref)[32] = &params_arr;
25552         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
25553         uint64_t ret_ref = 0;
25554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25555         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25556         return ret_ref;
25557 }
25558
25559 uint64_t  __attribute__((export_name("TS_KeysManager_spend_spendable_outputs"))) TS_KeysManager_spend_spendable_outputs(uint64_t this_arg, uint64_tArray descriptors, uint64_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight) {
25560         LDKKeysManager this_arg_conv;
25561         this_arg_conv.inner = untag_ptr(this_arg);
25562         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25564         this_arg_conv.is_owned = false;
25565         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
25566         descriptors_constr.datalen = descriptors->arr_len;
25567         if (descriptors_constr.datalen > 0)
25568                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
25569         else
25570                 descriptors_constr.data = NULL;
25571         uint64_t* descriptors_vals = descriptors->elems;
25572         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
25573                 uint64_t descriptors_conv_27 = descriptors_vals[b];
25574                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
25575                 CHECK_ACCESS(descriptors_conv_27_ptr);
25576                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
25577                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
25578                 descriptors_constr.data[b] = descriptors_conv_27_conv;
25579         }
25580         FREE(descriptors);
25581         LDKCVec_TxOutZ outputs_constr;
25582         outputs_constr.datalen = outputs->arr_len;
25583         if (outputs_constr.datalen > 0)
25584                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
25585         else
25586                 outputs_constr.data = NULL;
25587         uint64_t* outputs_vals = outputs->elems;
25588         for (size_t h = 0; h < outputs_constr.datalen; h++) {
25589                 uint64_t outputs_conv_7 = outputs_vals[h];
25590                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
25591                 CHECK_ACCESS(outputs_conv_7_ptr);
25592                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
25593                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
25594                 outputs_constr.data[h] = outputs_conv_7_conv;
25595         }
25596         FREE(outputs);
25597         LDKCVec_u8Z change_destination_script_ref;
25598         change_destination_script_ref.datalen = change_destination_script->arr_len;
25599         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
25600         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
25601         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
25602         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
25603         return tag_ptr(ret_conv, true);
25604 }
25605
25606 uint64_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint64_t this_arg) {
25607         LDKKeysManager this_arg_conv;
25608         this_arg_conv.inner = untag_ptr(this_arg);
25609         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25611         this_arg_conv.is_owned = false;
25612         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
25613         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
25614         return tag_ptr(ret_ret, true);
25615 }
25616
25617 void  __attribute__((export_name("TS_PhantomKeysManager_free"))) TS_PhantomKeysManager_free(uint64_t this_obj) {
25618         LDKPhantomKeysManager this_obj_conv;
25619         this_obj_conv.inner = untag_ptr(this_obj);
25620         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25622         PhantomKeysManager_free(this_obj_conv);
25623 }
25624
25625 uint64_t  __attribute__((export_name("TS_PhantomKeysManager_as_KeysInterface"))) TS_PhantomKeysManager_as_KeysInterface(uint64_t this_arg) {
25626         LDKPhantomKeysManager this_arg_conv;
25627         this_arg_conv.inner = untag_ptr(this_arg);
25628         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25630         this_arg_conv.is_owned = false;
25631         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
25632         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
25633         return tag_ptr(ret_ret, true);
25634 }
25635
25636 uint64_t  __attribute__((export_name("TS_PhantomKeysManager_new"))) TS_PhantomKeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos, int8_tArray cross_node_seed) {
25637         unsigned char seed_arr[32];
25638         CHECK(seed->arr_len == 32);
25639         memcpy(seed_arr, seed->elems, 32); FREE(seed);
25640         unsigned char (*seed_ref)[32] = &seed_arr;
25641         unsigned char cross_node_seed_arr[32];
25642         CHECK(cross_node_seed->arr_len == 32);
25643         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
25644         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
25645         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
25646         uint64_t ret_ref = 0;
25647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25648         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25649         return ret_ref;
25650 }
25651
25652 uint64_t  __attribute__((export_name("TS_PhantomKeysManager_spend_spendable_outputs"))) TS_PhantomKeysManager_spend_spendable_outputs(uint64_t this_arg, uint64_tArray descriptors, uint64_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight) {
25653         LDKPhantomKeysManager this_arg_conv;
25654         this_arg_conv.inner = untag_ptr(this_arg);
25655         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25657         this_arg_conv.is_owned = false;
25658         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
25659         descriptors_constr.datalen = descriptors->arr_len;
25660         if (descriptors_constr.datalen > 0)
25661                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
25662         else
25663                 descriptors_constr.data = NULL;
25664         uint64_t* descriptors_vals = descriptors->elems;
25665         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
25666                 uint64_t descriptors_conv_27 = descriptors_vals[b];
25667                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
25668                 CHECK_ACCESS(descriptors_conv_27_ptr);
25669                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
25670                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
25671                 descriptors_constr.data[b] = descriptors_conv_27_conv;
25672         }
25673         FREE(descriptors);
25674         LDKCVec_TxOutZ outputs_constr;
25675         outputs_constr.datalen = outputs->arr_len;
25676         if (outputs_constr.datalen > 0)
25677                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
25678         else
25679                 outputs_constr.data = NULL;
25680         uint64_t* outputs_vals = outputs->elems;
25681         for (size_t h = 0; h < outputs_constr.datalen; h++) {
25682                 uint64_t outputs_conv_7 = outputs_vals[h];
25683                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
25684                 CHECK_ACCESS(outputs_conv_7_ptr);
25685                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
25686                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
25687                 outputs_constr.data[h] = outputs_conv_7_conv;
25688         }
25689         FREE(outputs);
25690         LDKCVec_u8Z change_destination_script_ref;
25691         change_destination_script_ref.datalen = change_destination_script->arr_len;
25692         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
25693         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
25694         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
25695         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
25696         return tag_ptr(ret_conv, true);
25697 }
25698
25699 uint64_t  __attribute__((export_name("TS_PhantomKeysManager_derive_channel_keys"))) TS_PhantomKeysManager_derive_channel_keys(uint64_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
25700         LDKPhantomKeysManager this_arg_conv;
25701         this_arg_conv.inner = untag_ptr(this_arg);
25702         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25704         this_arg_conv.is_owned = false;
25705         unsigned char params_arr[32];
25706         CHECK(params->arr_len == 32);
25707         memcpy(params_arr, params->elems, 32); FREE(params);
25708         unsigned char (*params_ref)[32] = &params_arr;
25709         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
25710         uint64_t ret_ref = 0;
25711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25712         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25713         return ret_ref;
25714 }
25715
25716 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint64_t this_obj) {
25717         LDKChannelManager this_obj_conv;
25718         this_obj_conv.inner = untag_ptr(this_obj);
25719         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25721         ChannelManager_free(this_obj_conv);
25722 }
25723
25724 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint64_t this_obj) {
25725         LDKChainParameters this_obj_conv;
25726         this_obj_conv.inner = untag_ptr(this_obj);
25727         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25729         ChainParameters_free(this_obj_conv);
25730 }
25731
25732 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint64_t this_ptr) {
25733         LDKChainParameters this_ptr_conv;
25734         this_ptr_conv.inner = untag_ptr(this_ptr);
25735         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25737         this_ptr_conv.is_owned = false;
25738         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
25739         return ret_conv;
25740 }
25741
25742 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint64_t this_ptr, uint32_t val) {
25743         LDKChainParameters this_ptr_conv;
25744         this_ptr_conv.inner = untag_ptr(this_ptr);
25745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25747         this_ptr_conv.is_owned = false;
25748         LDKNetwork val_conv = LDKNetwork_from_js(val);
25749         ChainParameters_set_network(&this_ptr_conv, val_conv);
25750 }
25751
25752 uint64_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint64_t this_ptr) {
25753         LDKChainParameters this_ptr_conv;
25754         this_ptr_conv.inner = untag_ptr(this_ptr);
25755         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25757         this_ptr_conv.is_owned = false;
25758         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
25759         uint64_t ret_ref = 0;
25760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25762         return ret_ref;
25763 }
25764
25765 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint64_t this_ptr, uint64_t val) {
25766         LDKChainParameters this_ptr_conv;
25767         this_ptr_conv.inner = untag_ptr(this_ptr);
25768         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25770         this_ptr_conv.is_owned = false;
25771         LDKBestBlock val_conv;
25772         val_conv.inner = untag_ptr(val);
25773         val_conv.is_owned = ptr_is_owned(val);
25774         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25775         val_conv = BestBlock_clone(&val_conv);
25776         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
25777 }
25778
25779 uint64_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint64_t best_block_arg) {
25780         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
25781         LDKBestBlock best_block_arg_conv;
25782         best_block_arg_conv.inner = untag_ptr(best_block_arg);
25783         best_block_arg_conv.is_owned = ptr_is_owned(best_block_arg);
25784         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
25785         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
25786         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
25787         uint64_t ret_ref = 0;
25788         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25789         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25790         return ret_ref;
25791 }
25792
25793 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
25794         LDKChainParameters ret_var = ChainParameters_clone(arg);
25795         uint64_t ret_ref = 0;
25796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25798         return ret_ref;
25799 }
25800 int64_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint64_t arg) {
25801         LDKChainParameters arg_conv;
25802         arg_conv.inner = untag_ptr(arg);
25803         arg_conv.is_owned = ptr_is_owned(arg);
25804         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25805         arg_conv.is_owned = false;
25806         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
25807         return ret_conv;
25808 }
25809
25810 uint64_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint64_t orig) {
25811         LDKChainParameters orig_conv;
25812         orig_conv.inner = untag_ptr(orig);
25813         orig_conv.is_owned = ptr_is_owned(orig);
25814         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25815         orig_conv.is_owned = false;
25816         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
25817         uint64_t ret_ref = 0;
25818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25819         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25820         return ret_ref;
25821 }
25822
25823 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint64_t this_obj) {
25824         LDKCounterpartyForwardingInfo this_obj_conv;
25825         this_obj_conv.inner = untag_ptr(this_obj);
25826         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25828         CounterpartyForwardingInfo_free(this_obj_conv);
25829 }
25830
25831 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint64_t this_ptr) {
25832         LDKCounterpartyForwardingInfo this_ptr_conv;
25833         this_ptr_conv.inner = untag_ptr(this_ptr);
25834         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25836         this_ptr_conv.is_owned = false;
25837         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
25838         return ret_conv;
25839 }
25840
25841 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint64_t this_ptr, int32_t val) {
25842         LDKCounterpartyForwardingInfo this_ptr_conv;
25843         this_ptr_conv.inner = untag_ptr(this_ptr);
25844         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25846         this_ptr_conv.is_owned = false;
25847         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
25848 }
25849
25850 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint64_t this_ptr) {
25851         LDKCounterpartyForwardingInfo this_ptr_conv;
25852         this_ptr_conv.inner = untag_ptr(this_ptr);
25853         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25855         this_ptr_conv.is_owned = false;
25856         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
25857         return ret_conv;
25858 }
25859
25860 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint64_t this_ptr, int32_t val) {
25861         LDKCounterpartyForwardingInfo this_ptr_conv;
25862         this_ptr_conv.inner = untag_ptr(this_ptr);
25863         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25865         this_ptr_conv.is_owned = false;
25866         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
25867 }
25868
25869 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint64_t this_ptr) {
25870         LDKCounterpartyForwardingInfo this_ptr_conv;
25871         this_ptr_conv.inner = untag_ptr(this_ptr);
25872         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25874         this_ptr_conv.is_owned = false;
25875         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
25876         return ret_conv;
25877 }
25878
25879 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint64_t this_ptr, int16_t val) {
25880         LDKCounterpartyForwardingInfo this_ptr_conv;
25881         this_ptr_conv.inner = untag_ptr(this_ptr);
25882         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25884         this_ptr_conv.is_owned = false;
25885         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
25886 }
25887
25888 uint64_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_new"))) TS_CounterpartyForwardingInfo_new(int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg) {
25889         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
25890         uint64_t ret_ref = 0;
25891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25892         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25893         return ret_ref;
25894 }
25895
25896 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
25897         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
25898         uint64_t ret_ref = 0;
25899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25900         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25901         return ret_ref;
25902 }
25903 int64_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint64_t arg) {
25904         LDKCounterpartyForwardingInfo arg_conv;
25905         arg_conv.inner = untag_ptr(arg);
25906         arg_conv.is_owned = ptr_is_owned(arg);
25907         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25908         arg_conv.is_owned = false;
25909         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
25910         return ret_conv;
25911 }
25912
25913 uint64_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint64_t orig) {
25914         LDKCounterpartyForwardingInfo orig_conv;
25915         orig_conv.inner = untag_ptr(orig);
25916         orig_conv.is_owned = ptr_is_owned(orig);
25917         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25918         orig_conv.is_owned = false;
25919         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
25920         uint64_t ret_ref = 0;
25921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25922         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25923         return ret_ref;
25924 }
25925
25926 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint64_t this_obj) {
25927         LDKChannelCounterparty this_obj_conv;
25928         this_obj_conv.inner = untag_ptr(this_obj);
25929         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25931         ChannelCounterparty_free(this_obj_conv);
25932 }
25933
25934 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint64_t this_ptr) {
25935         LDKChannelCounterparty this_ptr_conv;
25936         this_ptr_conv.inner = untag_ptr(this_ptr);
25937         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25939         this_ptr_conv.is_owned = false;
25940         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25941         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
25942         return ret_arr;
25943 }
25944
25945 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint64_t this_ptr, int8_tArray val) {
25946         LDKChannelCounterparty this_ptr_conv;
25947         this_ptr_conv.inner = untag_ptr(this_ptr);
25948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25950         this_ptr_conv.is_owned = false;
25951         LDKPublicKey val_ref;
25952         CHECK(val->arr_len == 33);
25953         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25954         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
25955 }
25956
25957 uint64_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint64_t this_ptr) {
25958         LDKChannelCounterparty this_ptr_conv;
25959         this_ptr_conv.inner = untag_ptr(this_ptr);
25960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25962         this_ptr_conv.is_owned = false;
25963         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
25964         uint64_t ret_ref = 0;
25965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25966         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25967         return ret_ref;
25968 }
25969
25970 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint64_t this_ptr, uint64_t val) {
25971         LDKChannelCounterparty this_ptr_conv;
25972         this_ptr_conv.inner = untag_ptr(this_ptr);
25973         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25975         this_ptr_conv.is_owned = false;
25976         LDKInitFeatures val_conv;
25977         val_conv.inner = untag_ptr(val);
25978         val_conv.is_owned = ptr_is_owned(val);
25979         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25980         val_conv = InitFeatures_clone(&val_conv);
25981         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
25982 }
25983
25984 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint64_t this_ptr) {
25985         LDKChannelCounterparty this_ptr_conv;
25986         this_ptr_conv.inner = untag_ptr(this_ptr);
25987         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25989         this_ptr_conv.is_owned = false;
25990         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
25991         return ret_conv;
25992 }
25993
25994 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint64_t this_ptr, int64_t val) {
25995         LDKChannelCounterparty this_ptr_conv;
25996         this_ptr_conv.inner = untag_ptr(this_ptr);
25997         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25999         this_ptr_conv.is_owned = false;
26000         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
26001 }
26002
26003 uint64_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint64_t this_ptr) {
26004         LDKChannelCounterparty this_ptr_conv;
26005         this_ptr_conv.inner = untag_ptr(this_ptr);
26006         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26008         this_ptr_conv.is_owned = false;
26009         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
26010         uint64_t ret_ref = 0;
26011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26012         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26013         return ret_ref;
26014 }
26015
26016 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint64_t this_ptr, uint64_t val) {
26017         LDKChannelCounterparty this_ptr_conv;
26018         this_ptr_conv.inner = untag_ptr(this_ptr);
26019         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26021         this_ptr_conv.is_owned = false;
26022         LDKCounterpartyForwardingInfo val_conv;
26023         val_conv.inner = untag_ptr(val);
26024         val_conv.is_owned = ptr_is_owned(val);
26025         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26026         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
26027         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
26028 }
26029
26030 uint64_t  __attribute__((export_name("TS_ChannelCounterparty_get_outbound_htlc_minimum_msat"))) TS_ChannelCounterparty_get_outbound_htlc_minimum_msat(uint64_t this_ptr) {
26031         LDKChannelCounterparty this_ptr_conv;
26032         this_ptr_conv.inner = untag_ptr(this_ptr);
26033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26035         this_ptr_conv.is_owned = false;
26036         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26037         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
26038         uint64_t ret_ref = tag_ptr(ret_copy, true);
26039         return ret_ref;
26040 }
26041
26042 void  __attribute__((export_name("TS_ChannelCounterparty_set_outbound_htlc_minimum_msat"))) TS_ChannelCounterparty_set_outbound_htlc_minimum_msat(uint64_t this_ptr, uint64_t val) {
26043         LDKChannelCounterparty this_ptr_conv;
26044         this_ptr_conv.inner = untag_ptr(this_ptr);
26045         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26047         this_ptr_conv.is_owned = false;
26048         void* val_ptr = untag_ptr(val);
26049         CHECK_ACCESS(val_ptr);
26050         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26051         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
26052         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
26053 }
26054
26055 uint64_t  __attribute__((export_name("TS_ChannelCounterparty_get_outbound_htlc_maximum_msat"))) TS_ChannelCounterparty_get_outbound_htlc_maximum_msat(uint64_t this_ptr) {
26056         LDKChannelCounterparty this_ptr_conv;
26057         this_ptr_conv.inner = untag_ptr(this_ptr);
26058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26060         this_ptr_conv.is_owned = false;
26061         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26062         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
26063         uint64_t ret_ref = tag_ptr(ret_copy, true);
26064         return ret_ref;
26065 }
26066
26067 void  __attribute__((export_name("TS_ChannelCounterparty_set_outbound_htlc_maximum_msat"))) TS_ChannelCounterparty_set_outbound_htlc_maximum_msat(uint64_t this_ptr, uint64_t val) {
26068         LDKChannelCounterparty this_ptr_conv;
26069         this_ptr_conv.inner = untag_ptr(this_ptr);
26070         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26072         this_ptr_conv.is_owned = false;
26073         void* val_ptr = untag_ptr(val);
26074         CHECK_ACCESS(val_ptr);
26075         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26076         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
26077         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
26078 }
26079
26080 uint64_t  __attribute__((export_name("TS_ChannelCounterparty_new"))) TS_ChannelCounterparty_new(int8_tArray node_id_arg, uint64_t features_arg, int64_t unspendable_punishment_reserve_arg, uint64_t forwarding_info_arg, uint64_t outbound_htlc_minimum_msat_arg, uint64_t outbound_htlc_maximum_msat_arg) {
26081         LDKPublicKey node_id_arg_ref;
26082         CHECK(node_id_arg->arr_len == 33);
26083         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
26084         LDKInitFeatures features_arg_conv;
26085         features_arg_conv.inner = untag_ptr(features_arg);
26086         features_arg_conv.is_owned = ptr_is_owned(features_arg);
26087         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
26088         features_arg_conv = InitFeatures_clone(&features_arg_conv);
26089         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
26090         forwarding_info_arg_conv.inner = untag_ptr(forwarding_info_arg);
26091         forwarding_info_arg_conv.is_owned = ptr_is_owned(forwarding_info_arg);
26092         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
26093         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
26094         void* outbound_htlc_minimum_msat_arg_ptr = untag_ptr(outbound_htlc_minimum_msat_arg);
26095         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
26096         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
26097         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_minimum_msat_arg));
26098         void* outbound_htlc_maximum_msat_arg_ptr = untag_ptr(outbound_htlc_maximum_msat_arg);
26099         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
26100         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
26101         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_maximum_msat_arg));
26102         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv, outbound_htlc_minimum_msat_arg_conv, outbound_htlc_maximum_msat_arg_conv);
26103         uint64_t ret_ref = 0;
26104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26105         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26106         return ret_ref;
26107 }
26108
26109 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
26110         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
26111         uint64_t ret_ref = 0;
26112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26113         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26114         return ret_ref;
26115 }
26116 int64_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint64_t arg) {
26117         LDKChannelCounterparty arg_conv;
26118         arg_conv.inner = untag_ptr(arg);
26119         arg_conv.is_owned = ptr_is_owned(arg);
26120         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26121         arg_conv.is_owned = false;
26122         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
26123         return ret_conv;
26124 }
26125
26126 uint64_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint64_t orig) {
26127         LDKChannelCounterparty orig_conv;
26128         orig_conv.inner = untag_ptr(orig);
26129         orig_conv.is_owned = ptr_is_owned(orig);
26130         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26131         orig_conv.is_owned = false;
26132         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
26133         uint64_t ret_ref = 0;
26134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26135         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26136         return ret_ref;
26137 }
26138
26139 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint64_t this_obj) {
26140         LDKChannelDetails this_obj_conv;
26141         this_obj_conv.inner = untag_ptr(this_obj);
26142         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26144         ChannelDetails_free(this_obj_conv);
26145 }
26146
26147 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint64_t this_ptr) {
26148         LDKChannelDetails this_ptr_conv;
26149         this_ptr_conv.inner = untag_ptr(this_ptr);
26150         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26152         this_ptr_conv.is_owned = false;
26153         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26154         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
26155         return ret_arr;
26156 }
26157
26158 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint64_t this_ptr, int8_tArray val) {
26159         LDKChannelDetails this_ptr_conv;
26160         this_ptr_conv.inner = untag_ptr(this_ptr);
26161         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26163         this_ptr_conv.is_owned = false;
26164         LDKThirtyTwoBytes val_ref;
26165         CHECK(val->arr_len == 32);
26166         memcpy(val_ref.data, val->elems, 32); FREE(val);
26167         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
26168 }
26169
26170 uint64_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint64_t this_ptr) {
26171         LDKChannelDetails this_ptr_conv;
26172         this_ptr_conv.inner = untag_ptr(this_ptr);
26173         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26175         this_ptr_conv.is_owned = false;
26176         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
26177         uint64_t ret_ref = 0;
26178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26179         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26180         return ret_ref;
26181 }
26182
26183 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint64_t this_ptr, uint64_t val) {
26184         LDKChannelDetails this_ptr_conv;
26185         this_ptr_conv.inner = untag_ptr(this_ptr);
26186         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26188         this_ptr_conv.is_owned = false;
26189         LDKChannelCounterparty val_conv;
26190         val_conv.inner = untag_ptr(val);
26191         val_conv.is_owned = ptr_is_owned(val);
26192         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26193         val_conv = ChannelCounterparty_clone(&val_conv);
26194         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
26195 }
26196
26197 uint64_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint64_t this_ptr) {
26198         LDKChannelDetails this_ptr_conv;
26199         this_ptr_conv.inner = untag_ptr(this_ptr);
26200         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26202         this_ptr_conv.is_owned = false;
26203         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
26204         uint64_t ret_ref = 0;
26205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26206         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26207         return ret_ref;
26208 }
26209
26210 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint64_t this_ptr, uint64_t val) {
26211         LDKChannelDetails this_ptr_conv;
26212         this_ptr_conv.inner = untag_ptr(this_ptr);
26213         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26215         this_ptr_conv.is_owned = false;
26216         LDKOutPoint val_conv;
26217         val_conv.inner = untag_ptr(val);
26218         val_conv.is_owned = ptr_is_owned(val);
26219         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26220         val_conv = OutPoint_clone(&val_conv);
26221         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
26222 }
26223
26224 uint64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_type"))) TS_ChannelDetails_get_channel_type(uint64_t this_ptr) {
26225         LDKChannelDetails this_ptr_conv;
26226         this_ptr_conv.inner = untag_ptr(this_ptr);
26227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26229         this_ptr_conv.is_owned = false;
26230         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
26231         uint64_t ret_ref = 0;
26232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26233         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26234         return ret_ref;
26235 }
26236
26237 void  __attribute__((export_name("TS_ChannelDetails_set_channel_type"))) TS_ChannelDetails_set_channel_type(uint64_t this_ptr, uint64_t val) {
26238         LDKChannelDetails this_ptr_conv;
26239         this_ptr_conv.inner = untag_ptr(this_ptr);
26240         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26242         this_ptr_conv.is_owned = false;
26243         LDKChannelTypeFeatures val_conv;
26244         val_conv.inner = untag_ptr(val);
26245         val_conv.is_owned = ptr_is_owned(val);
26246         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26247         val_conv = ChannelTypeFeatures_clone(&val_conv);
26248         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
26249 }
26250
26251 uint64_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint64_t this_ptr) {
26252         LDKChannelDetails this_ptr_conv;
26253         this_ptr_conv.inner = untag_ptr(this_ptr);
26254         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26256         this_ptr_conv.is_owned = false;
26257         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26258         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
26259         uint64_t ret_ref = tag_ptr(ret_copy, true);
26260         return ret_ref;
26261 }
26262
26263 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint64_t this_ptr, uint64_t val) {
26264         LDKChannelDetails this_ptr_conv;
26265         this_ptr_conv.inner = untag_ptr(this_ptr);
26266         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26268         this_ptr_conv.is_owned = false;
26269         void* val_ptr = untag_ptr(val);
26270         CHECK_ACCESS(val_ptr);
26271         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26272         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
26273         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
26274 }
26275
26276 uint64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_scid_alias"))) TS_ChannelDetails_get_outbound_scid_alias(uint64_t this_ptr) {
26277         LDKChannelDetails this_ptr_conv;
26278         this_ptr_conv.inner = untag_ptr(this_ptr);
26279         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26281         this_ptr_conv.is_owned = false;
26282         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26283         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
26284         uint64_t ret_ref = tag_ptr(ret_copy, true);
26285         return ret_ref;
26286 }
26287
26288 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_scid_alias"))) TS_ChannelDetails_set_outbound_scid_alias(uint64_t this_ptr, uint64_t val) {
26289         LDKChannelDetails this_ptr_conv;
26290         this_ptr_conv.inner = untag_ptr(this_ptr);
26291         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26293         this_ptr_conv.is_owned = false;
26294         void* val_ptr = untag_ptr(val);
26295         CHECK_ACCESS(val_ptr);
26296         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26297         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
26298         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
26299 }
26300
26301 uint64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_scid_alias"))) TS_ChannelDetails_get_inbound_scid_alias(uint64_t this_ptr) {
26302         LDKChannelDetails this_ptr_conv;
26303         this_ptr_conv.inner = untag_ptr(this_ptr);
26304         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26306         this_ptr_conv.is_owned = false;
26307         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26308         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
26309         uint64_t ret_ref = tag_ptr(ret_copy, true);
26310         return ret_ref;
26311 }
26312
26313 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_scid_alias"))) TS_ChannelDetails_set_inbound_scid_alias(uint64_t this_ptr, uint64_t val) {
26314         LDKChannelDetails this_ptr_conv;
26315         this_ptr_conv.inner = untag_ptr(this_ptr);
26316         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26318         this_ptr_conv.is_owned = false;
26319         void* val_ptr = untag_ptr(val);
26320         CHECK_ACCESS(val_ptr);
26321         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26322         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
26323         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
26324 }
26325
26326 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint64_t this_ptr) {
26327         LDKChannelDetails this_ptr_conv;
26328         this_ptr_conv.inner = untag_ptr(this_ptr);
26329         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26331         this_ptr_conv.is_owned = false;
26332         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
26333         return ret_conv;
26334 }
26335
26336 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint64_t this_ptr, int64_t val) {
26337         LDKChannelDetails this_ptr_conv;
26338         this_ptr_conv.inner = untag_ptr(this_ptr);
26339         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26341         this_ptr_conv.is_owned = false;
26342         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
26343 }
26344
26345 uint64_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint64_t this_ptr) {
26346         LDKChannelDetails this_ptr_conv;
26347         this_ptr_conv.inner = untag_ptr(this_ptr);
26348         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26350         this_ptr_conv.is_owned = false;
26351         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26352         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
26353         uint64_t ret_ref = tag_ptr(ret_copy, true);
26354         return ret_ref;
26355 }
26356
26357 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint64_t this_ptr, uint64_t val) {
26358         LDKChannelDetails this_ptr_conv;
26359         this_ptr_conv.inner = untag_ptr(this_ptr);
26360         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26362         this_ptr_conv.is_owned = false;
26363         void* val_ptr = untag_ptr(val);
26364         CHECK_ACCESS(val_ptr);
26365         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26366         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
26367         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
26368 }
26369
26370 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint64_t this_ptr) {
26371         LDKChannelDetails this_ptr_conv;
26372         this_ptr_conv.inner = untag_ptr(this_ptr);
26373         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26375         this_ptr_conv.is_owned = false;
26376         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
26377         return ret_conv;
26378 }
26379
26380 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint64_t this_ptr, int64_t val) {
26381         LDKChannelDetails this_ptr_conv;
26382         this_ptr_conv.inner = untag_ptr(this_ptr);
26383         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26385         this_ptr_conv.is_owned = false;
26386         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
26387 }
26388
26389 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint64_t this_ptr) {
26390         LDKChannelDetails this_ptr_conv;
26391         this_ptr_conv.inner = untag_ptr(this_ptr);
26392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26394         this_ptr_conv.is_owned = false;
26395         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
26396         return ret_conv;
26397 }
26398
26399 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint64_t this_ptr, int64_t val) {
26400         LDKChannelDetails this_ptr_conv;
26401         this_ptr_conv.inner = untag_ptr(this_ptr);
26402         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26404         this_ptr_conv.is_owned = false;
26405         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
26406 }
26407
26408 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint64_t this_ptr) {
26409         LDKChannelDetails this_ptr_conv;
26410         this_ptr_conv.inner = untag_ptr(this_ptr);
26411         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26413         this_ptr_conv.is_owned = false;
26414         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
26415         return ret_conv;
26416 }
26417
26418 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint64_t this_ptr, int64_t val) {
26419         LDKChannelDetails this_ptr_conv;
26420         this_ptr_conv.inner = untag_ptr(this_ptr);
26421         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26423         this_ptr_conv.is_owned = false;
26424         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
26425 }
26426
26427 int64_t  __attribute__((export_name("TS_ChannelDetails_get_next_outbound_htlc_limit_msat"))) TS_ChannelDetails_get_next_outbound_htlc_limit_msat(uint64_t this_ptr) {
26428         LDKChannelDetails this_ptr_conv;
26429         this_ptr_conv.inner = untag_ptr(this_ptr);
26430         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26432         this_ptr_conv.is_owned = false;
26433         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
26434         return ret_conv;
26435 }
26436
26437 void  __attribute__((export_name("TS_ChannelDetails_set_next_outbound_htlc_limit_msat"))) TS_ChannelDetails_set_next_outbound_htlc_limit_msat(uint64_t this_ptr, int64_t val) {
26438         LDKChannelDetails this_ptr_conv;
26439         this_ptr_conv.inner = untag_ptr(this_ptr);
26440         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26442         this_ptr_conv.is_owned = false;
26443         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
26444 }
26445
26446 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint64_t this_ptr) {
26447         LDKChannelDetails this_ptr_conv;
26448         this_ptr_conv.inner = untag_ptr(this_ptr);
26449         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26451         this_ptr_conv.is_owned = false;
26452         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
26453         return ret_conv;
26454 }
26455
26456 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint64_t this_ptr, int64_t val) {
26457         LDKChannelDetails this_ptr_conv;
26458         this_ptr_conv.inner = untag_ptr(this_ptr);
26459         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26461         this_ptr_conv.is_owned = false;
26462         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
26463 }
26464
26465 uint64_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint64_t this_ptr) {
26466         LDKChannelDetails this_ptr_conv;
26467         this_ptr_conv.inner = untag_ptr(this_ptr);
26468         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26470         this_ptr_conv.is_owned = false;
26471         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
26472         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
26473         uint64_t ret_ref = tag_ptr(ret_copy, true);
26474         return ret_ref;
26475 }
26476
26477 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint64_t this_ptr, uint64_t val) {
26478         LDKChannelDetails this_ptr_conv;
26479         this_ptr_conv.inner = untag_ptr(this_ptr);
26480         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26482         this_ptr_conv.is_owned = false;
26483         void* val_ptr = untag_ptr(val);
26484         CHECK_ACCESS(val_ptr);
26485         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
26486         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
26487         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
26488 }
26489
26490 uint64_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint64_t this_ptr) {
26491         LDKChannelDetails this_ptr_conv;
26492         this_ptr_conv.inner = untag_ptr(this_ptr);
26493         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26495         this_ptr_conv.is_owned = false;
26496         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
26497         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
26498         uint64_t ret_ref = tag_ptr(ret_copy, true);
26499         return ret_ref;
26500 }
26501
26502 void  __attribute__((export_name("TS_ChannelDetails_set_force_close_spend_delay"))) TS_ChannelDetails_set_force_close_spend_delay(uint64_t this_ptr, uint64_t val) {
26503         LDKChannelDetails this_ptr_conv;
26504         this_ptr_conv.inner = untag_ptr(this_ptr);
26505         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26507         this_ptr_conv.is_owned = false;
26508         void* val_ptr = untag_ptr(val);
26509         CHECK_ACCESS(val_ptr);
26510         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
26511         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
26512         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
26513 }
26514
26515 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint64_t this_ptr) {
26516         LDKChannelDetails this_ptr_conv;
26517         this_ptr_conv.inner = untag_ptr(this_ptr);
26518         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26520         this_ptr_conv.is_owned = false;
26521         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
26522         return ret_conv;
26523 }
26524
26525 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint64_t this_ptr, jboolean val) {
26526         LDKChannelDetails this_ptr_conv;
26527         this_ptr_conv.inner = untag_ptr(this_ptr);
26528         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26530         this_ptr_conv.is_owned = false;
26531         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
26532 }
26533
26534 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_channel_ready"))) TS_ChannelDetails_get_is_channel_ready(uint64_t this_ptr) {
26535         LDKChannelDetails this_ptr_conv;
26536         this_ptr_conv.inner = untag_ptr(this_ptr);
26537         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26539         this_ptr_conv.is_owned = false;
26540         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
26541         return ret_conv;
26542 }
26543
26544 void  __attribute__((export_name("TS_ChannelDetails_set_is_channel_ready"))) TS_ChannelDetails_set_is_channel_ready(uint64_t this_ptr, jboolean val) {
26545         LDKChannelDetails this_ptr_conv;
26546         this_ptr_conv.inner = untag_ptr(this_ptr);
26547         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26549         this_ptr_conv.is_owned = false;
26550         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
26551 }
26552
26553 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint64_t this_ptr) {
26554         LDKChannelDetails this_ptr_conv;
26555         this_ptr_conv.inner = untag_ptr(this_ptr);
26556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26558         this_ptr_conv.is_owned = false;
26559         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
26560         return ret_conv;
26561 }
26562
26563 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint64_t this_ptr, jboolean val) {
26564         LDKChannelDetails this_ptr_conv;
26565         this_ptr_conv.inner = untag_ptr(this_ptr);
26566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26568         this_ptr_conv.is_owned = false;
26569         ChannelDetails_set_is_usable(&this_ptr_conv, val);
26570 }
26571
26572 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint64_t this_ptr) {
26573         LDKChannelDetails this_ptr_conv;
26574         this_ptr_conv.inner = untag_ptr(this_ptr);
26575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26577         this_ptr_conv.is_owned = false;
26578         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
26579         return ret_conv;
26580 }
26581
26582 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint64_t this_ptr, jboolean val) {
26583         LDKChannelDetails this_ptr_conv;
26584         this_ptr_conv.inner = untag_ptr(this_ptr);
26585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26587         this_ptr_conv.is_owned = false;
26588         ChannelDetails_set_is_public(&this_ptr_conv, val);
26589 }
26590
26591 uint64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_htlc_minimum_msat"))) TS_ChannelDetails_get_inbound_htlc_minimum_msat(uint64_t this_ptr) {
26592         LDKChannelDetails this_ptr_conv;
26593         this_ptr_conv.inner = untag_ptr(this_ptr);
26594         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26596         this_ptr_conv.is_owned = false;
26597         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26598         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
26599         uint64_t ret_ref = tag_ptr(ret_copy, true);
26600         return ret_ref;
26601 }
26602
26603 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_htlc_minimum_msat"))) TS_ChannelDetails_set_inbound_htlc_minimum_msat(uint64_t this_ptr, uint64_t val) {
26604         LDKChannelDetails this_ptr_conv;
26605         this_ptr_conv.inner = untag_ptr(this_ptr);
26606         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26608         this_ptr_conv.is_owned = false;
26609         void* val_ptr = untag_ptr(val);
26610         CHECK_ACCESS(val_ptr);
26611         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26612         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
26613         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
26614 }
26615
26616 uint64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_htlc_maximum_msat"))) TS_ChannelDetails_get_inbound_htlc_maximum_msat(uint64_t this_ptr) {
26617         LDKChannelDetails this_ptr_conv;
26618         this_ptr_conv.inner = untag_ptr(this_ptr);
26619         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26621         this_ptr_conv.is_owned = false;
26622         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26623         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
26624         uint64_t ret_ref = tag_ptr(ret_copy, true);
26625         return ret_ref;
26626 }
26627
26628 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_htlc_maximum_msat"))) TS_ChannelDetails_set_inbound_htlc_maximum_msat(uint64_t this_ptr, uint64_t val) {
26629         LDKChannelDetails this_ptr_conv;
26630         this_ptr_conv.inner = untag_ptr(this_ptr);
26631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26633         this_ptr_conv.is_owned = false;
26634         void* val_ptr = untag_ptr(val);
26635         CHECK_ACCESS(val_ptr);
26636         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26637         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
26638         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
26639 }
26640
26641 uint64_t  __attribute__((export_name("TS_ChannelDetails_get_config"))) TS_ChannelDetails_get_config(uint64_t this_ptr) {
26642         LDKChannelDetails this_ptr_conv;
26643         this_ptr_conv.inner = untag_ptr(this_ptr);
26644         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26646         this_ptr_conv.is_owned = false;
26647         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
26648         uint64_t ret_ref = 0;
26649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26650         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26651         return ret_ref;
26652 }
26653
26654 void  __attribute__((export_name("TS_ChannelDetails_set_config"))) TS_ChannelDetails_set_config(uint64_t this_ptr, uint64_t val) {
26655         LDKChannelDetails this_ptr_conv;
26656         this_ptr_conv.inner = untag_ptr(this_ptr);
26657         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26659         this_ptr_conv.is_owned = false;
26660         LDKChannelConfig val_conv;
26661         val_conv.inner = untag_ptr(val);
26662         val_conv.is_owned = ptr_is_owned(val);
26663         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26664         val_conv = ChannelConfig_clone(&val_conv);
26665         ChannelDetails_set_config(&this_ptr_conv, val_conv);
26666 }
26667
26668 uint64_t  __attribute__((export_name("TS_ChannelDetails_new"))) TS_ChannelDetails_new(int8_tArray channel_id_arg, uint64_t counterparty_arg, uint64_t funding_txo_arg, uint64_t channel_type_arg, uint64_t short_channel_id_arg, uint64_t outbound_scid_alias_arg, uint64_t inbound_scid_alias_arg, int64_t channel_value_satoshis_arg, uint64_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t next_outbound_htlc_limit_msat_arg, int64_t inbound_capacity_msat_arg, uint64_t confirmations_required_arg, uint64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_channel_ready_arg, jboolean is_usable_arg, jboolean is_public_arg, uint64_t inbound_htlc_minimum_msat_arg, uint64_t inbound_htlc_maximum_msat_arg, uint64_t config_arg) {
26669         LDKThirtyTwoBytes channel_id_arg_ref;
26670         CHECK(channel_id_arg->arr_len == 32);
26671         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26672         LDKChannelCounterparty counterparty_arg_conv;
26673         counterparty_arg_conv.inner = untag_ptr(counterparty_arg);
26674         counterparty_arg_conv.is_owned = ptr_is_owned(counterparty_arg);
26675         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
26676         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
26677         LDKOutPoint funding_txo_arg_conv;
26678         funding_txo_arg_conv.inner = untag_ptr(funding_txo_arg);
26679         funding_txo_arg_conv.is_owned = ptr_is_owned(funding_txo_arg);
26680         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
26681         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
26682         LDKChannelTypeFeatures channel_type_arg_conv;
26683         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
26684         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
26685         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
26686         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
26687         void* short_channel_id_arg_ptr = untag_ptr(short_channel_id_arg);
26688         CHECK_ACCESS(short_channel_id_arg_ptr);
26689         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
26690         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_arg));
26691         void* outbound_scid_alias_arg_ptr = untag_ptr(outbound_scid_alias_arg);
26692         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
26693         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
26694         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_scid_alias_arg));
26695         void* inbound_scid_alias_arg_ptr = untag_ptr(inbound_scid_alias_arg);
26696         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
26697         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
26698         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_scid_alias_arg));
26699         void* unspendable_punishment_reserve_arg_ptr = untag_ptr(unspendable_punishment_reserve_arg);
26700         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
26701         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
26702         void* confirmations_required_arg_ptr = untag_ptr(confirmations_required_arg);
26703         CHECK_ACCESS(confirmations_required_arg_ptr);
26704         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
26705         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_required_arg));
26706         void* force_close_spend_delay_arg_ptr = untag_ptr(force_close_spend_delay_arg);
26707         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
26708         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
26709         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(force_close_spend_delay_arg));
26710         void* inbound_htlc_minimum_msat_arg_ptr = untag_ptr(inbound_htlc_minimum_msat_arg);
26711         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
26712         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
26713         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_minimum_msat_arg));
26714         void* inbound_htlc_maximum_msat_arg_ptr = untag_ptr(inbound_htlc_maximum_msat_arg);
26715         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
26716         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
26717         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_maximum_msat_arg));
26718         LDKChannelConfig config_arg_conv;
26719         config_arg_conv.inner = untag_ptr(config_arg);
26720         config_arg_conv.is_owned = ptr_is_owned(config_arg);
26721         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
26722         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
26723         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, channel_type_arg_conv, short_channel_id_arg_conv, outbound_scid_alias_arg_conv, inbound_scid_alias_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, next_outbound_htlc_limit_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_channel_ready_arg, is_usable_arg, is_public_arg, inbound_htlc_minimum_msat_arg_conv, inbound_htlc_maximum_msat_arg_conv, config_arg_conv);
26724         uint64_t ret_ref = 0;
26725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26726         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26727         return ret_ref;
26728 }
26729
26730 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
26731         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
26732         uint64_t ret_ref = 0;
26733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26735         return ret_ref;
26736 }
26737 int64_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint64_t arg) {
26738         LDKChannelDetails arg_conv;
26739         arg_conv.inner = untag_ptr(arg);
26740         arg_conv.is_owned = ptr_is_owned(arg);
26741         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26742         arg_conv.is_owned = false;
26743         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
26744         return ret_conv;
26745 }
26746
26747 uint64_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint64_t orig) {
26748         LDKChannelDetails orig_conv;
26749         orig_conv.inner = untag_ptr(orig);
26750         orig_conv.is_owned = ptr_is_owned(orig);
26751         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26752         orig_conv.is_owned = false;
26753         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
26754         uint64_t ret_ref = 0;
26755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26756         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26757         return ret_ref;
26758 }
26759
26760 uint64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_payment_scid"))) TS_ChannelDetails_get_inbound_payment_scid(uint64_t this_arg) {
26761         LDKChannelDetails this_arg_conv;
26762         this_arg_conv.inner = untag_ptr(this_arg);
26763         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26765         this_arg_conv.is_owned = false;
26766         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26767         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
26768         uint64_t ret_ref = tag_ptr(ret_copy, true);
26769         return ret_ref;
26770 }
26771
26772 uint64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_payment_scid"))) TS_ChannelDetails_get_outbound_payment_scid(uint64_t this_arg) {
26773         LDKChannelDetails this_arg_conv;
26774         this_arg_conv.inner = untag_ptr(this_arg);
26775         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26777         this_arg_conv.is_owned = false;
26778         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26779         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
26780         uint64_t ret_ref = tag_ptr(ret_copy, true);
26781         return ret_ref;
26782 }
26783
26784 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint64_t this_ptr) {
26785         if (!ptr_is_owned(this_ptr)) return;
26786         void* this_ptr_ptr = untag_ptr(this_ptr);
26787         CHECK_ACCESS(this_ptr_ptr);
26788         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
26789         FREE(untag_ptr(this_ptr));
26790         PaymentSendFailure_free(this_ptr_conv);
26791 }
26792
26793 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
26794         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26795         *ret_copy = PaymentSendFailure_clone(arg);
26796         uint64_t ret_ref = tag_ptr(ret_copy, true);
26797         return ret_ref;
26798 }
26799 int64_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint64_t arg) {
26800         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)untag_ptr(arg);
26801         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
26802         return ret_conv;
26803 }
26804
26805 uint64_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint64_t orig) {
26806         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)untag_ptr(orig);
26807         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26808         *ret_copy = PaymentSendFailure_clone(orig_conv);
26809         uint64_t ret_ref = tag_ptr(ret_copy, true);
26810         return ret_ref;
26811 }
26812
26813 uint64_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint64_t a) {
26814         void* a_ptr = untag_ptr(a);
26815         CHECK_ACCESS(a_ptr);
26816         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
26817         a_conv = APIError_clone((LDKAPIError*)untag_ptr(a));
26818         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26819         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
26820         uint64_t ret_ref = tag_ptr(ret_copy, true);
26821         return ret_ref;
26822 }
26823
26824 uint64_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint64_tArray a) {
26825         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
26826         a_constr.datalen = a->arr_len;
26827         if (a_constr.datalen > 0)
26828                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
26829         else
26830                 a_constr.data = NULL;
26831         uint64_t* a_vals = a->elems;
26832         for (size_t w = 0; w < a_constr.datalen; w++) {
26833                 uint64_t a_conv_22 = a_vals[w];
26834                 void* a_conv_22_ptr = untag_ptr(a_conv_22);
26835                 CHECK_ACCESS(a_conv_22_ptr);
26836                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
26837                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)untag_ptr(a_conv_22));
26838                 a_constr.data[w] = a_conv_22_conv;
26839         }
26840         FREE(a);
26841         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26842         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
26843         uint64_t ret_ref = tag_ptr(ret_copy, true);
26844         return ret_ref;
26845 }
26846
26847 uint64_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint64_tArray a) {
26848         LDKCVec_APIErrorZ a_constr;
26849         a_constr.datalen = a->arr_len;
26850         if (a_constr.datalen > 0)
26851                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
26852         else
26853                 a_constr.data = NULL;
26854         uint64_t* a_vals = a->elems;
26855         for (size_t k = 0; k < a_constr.datalen; k++) {
26856                 uint64_t a_conv_10 = a_vals[k];
26857                 void* a_conv_10_ptr = untag_ptr(a_conv_10);
26858                 CHECK_ACCESS(a_conv_10_ptr);
26859                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
26860                 a_conv_10_conv = APIError_clone((LDKAPIError*)untag_ptr(a_conv_10));
26861                 a_constr.data[k] = a_conv_10_conv;
26862         }
26863         FREE(a);
26864         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26865         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
26866         uint64_t ret_ref = tag_ptr(ret_copy, true);
26867         return ret_ref;
26868 }
26869
26870 uint64_t  __attribute__((export_name("TS_PaymentSendFailure_partial_failure"))) TS_PaymentSendFailure_partial_failure(uint64_tArray results, uint64_t failed_paths_retry, int8_tArray payment_id) {
26871         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
26872         results_constr.datalen = results->arr_len;
26873         if (results_constr.datalen > 0)
26874                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
26875         else
26876                 results_constr.data = NULL;
26877         uint64_t* results_vals = results->elems;
26878         for (size_t w = 0; w < results_constr.datalen; w++) {
26879                 uint64_t results_conv_22 = results_vals[w];
26880                 void* results_conv_22_ptr = untag_ptr(results_conv_22);
26881                 CHECK_ACCESS(results_conv_22_ptr);
26882                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
26883                 results_constr.data[w] = results_conv_22_conv;
26884         }
26885         FREE(results);
26886         LDKRouteParameters failed_paths_retry_conv;
26887         failed_paths_retry_conv.inner = untag_ptr(failed_paths_retry);
26888         failed_paths_retry_conv.is_owned = ptr_is_owned(failed_paths_retry);
26889         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
26890         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
26891         LDKThirtyTwoBytes payment_id_ref;
26892         CHECK(payment_id->arr_len == 32);
26893         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
26894         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26895         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
26896         uint64_t ret_ref = tag_ptr(ret_copy, true);
26897         return ret_ref;
26898 }
26899
26900 void  __attribute__((export_name("TS_PhantomRouteHints_free"))) TS_PhantomRouteHints_free(uint64_t this_obj) {
26901         LDKPhantomRouteHints this_obj_conv;
26902         this_obj_conv.inner = untag_ptr(this_obj);
26903         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26905         PhantomRouteHints_free(this_obj_conv);
26906 }
26907
26908 uint64_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_channels"))) TS_PhantomRouteHints_get_channels(uint64_t this_ptr) {
26909         LDKPhantomRouteHints this_ptr_conv;
26910         this_ptr_conv.inner = untag_ptr(this_ptr);
26911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26913         this_ptr_conv.is_owned = false;
26914         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
26915         uint64_tArray ret_arr = NULL;
26916         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
26917         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
26918         for (size_t q = 0; q < ret_var.datalen; q++) {
26919                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
26920                 uint64_t ret_conv_16_ref = 0;
26921                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26922                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
26923                 ret_arr_ptr[q] = ret_conv_16_ref;
26924         }
26925         
26926         FREE(ret_var.data);
26927         return ret_arr;
26928 }
26929
26930 void  __attribute__((export_name("TS_PhantomRouteHints_set_channels"))) TS_PhantomRouteHints_set_channels(uint64_t this_ptr, uint64_tArray val) {
26931         LDKPhantomRouteHints this_ptr_conv;
26932         this_ptr_conv.inner = untag_ptr(this_ptr);
26933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26935         this_ptr_conv.is_owned = false;
26936         LDKCVec_ChannelDetailsZ val_constr;
26937         val_constr.datalen = val->arr_len;
26938         if (val_constr.datalen > 0)
26939                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
26940         else
26941                 val_constr.data = NULL;
26942         uint64_t* val_vals = val->elems;
26943         for (size_t q = 0; q < val_constr.datalen; q++) {
26944                 uint64_t val_conv_16 = val_vals[q];
26945                 LDKChannelDetails val_conv_16_conv;
26946                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
26947                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
26948                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
26949                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
26950                 val_constr.data[q] = val_conv_16_conv;
26951         }
26952         FREE(val);
26953         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
26954 }
26955
26956 int64_t  __attribute__((export_name("TS_PhantomRouteHints_get_phantom_scid"))) TS_PhantomRouteHints_get_phantom_scid(uint64_t this_ptr) {
26957         LDKPhantomRouteHints this_ptr_conv;
26958         this_ptr_conv.inner = untag_ptr(this_ptr);
26959         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26961         this_ptr_conv.is_owned = false;
26962         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
26963         return ret_conv;
26964 }
26965
26966 void  __attribute__((export_name("TS_PhantomRouteHints_set_phantom_scid"))) TS_PhantomRouteHints_set_phantom_scid(uint64_t this_ptr, int64_t val) {
26967         LDKPhantomRouteHints this_ptr_conv;
26968         this_ptr_conv.inner = untag_ptr(this_ptr);
26969         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26971         this_ptr_conv.is_owned = false;
26972         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
26973 }
26974
26975 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_real_node_pubkey"))) TS_PhantomRouteHints_get_real_node_pubkey(uint64_t this_ptr) {
26976         LDKPhantomRouteHints this_ptr_conv;
26977         this_ptr_conv.inner = untag_ptr(this_ptr);
26978         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26980         this_ptr_conv.is_owned = false;
26981         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26982         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
26983         return ret_arr;
26984 }
26985
26986 void  __attribute__((export_name("TS_PhantomRouteHints_set_real_node_pubkey"))) TS_PhantomRouteHints_set_real_node_pubkey(uint64_t this_ptr, int8_tArray val) {
26987         LDKPhantomRouteHints this_ptr_conv;
26988         this_ptr_conv.inner = untag_ptr(this_ptr);
26989         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26991         this_ptr_conv.is_owned = false;
26992         LDKPublicKey val_ref;
26993         CHECK(val->arr_len == 33);
26994         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26995         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
26996 }
26997
26998 uint64_t  __attribute__((export_name("TS_PhantomRouteHints_new"))) TS_PhantomRouteHints_new(uint64_tArray channels_arg, int64_t phantom_scid_arg, int8_tArray real_node_pubkey_arg) {
26999         LDKCVec_ChannelDetailsZ channels_arg_constr;
27000         channels_arg_constr.datalen = channels_arg->arr_len;
27001         if (channels_arg_constr.datalen > 0)
27002                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
27003         else
27004                 channels_arg_constr.data = NULL;
27005         uint64_t* channels_arg_vals = channels_arg->elems;
27006         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
27007                 uint64_t channels_arg_conv_16 = channels_arg_vals[q];
27008                 LDKChannelDetails channels_arg_conv_16_conv;
27009                 channels_arg_conv_16_conv.inner = untag_ptr(channels_arg_conv_16);
27010                 channels_arg_conv_16_conv.is_owned = ptr_is_owned(channels_arg_conv_16);
27011                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
27012                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
27013                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
27014         }
27015         FREE(channels_arg);
27016         LDKPublicKey real_node_pubkey_arg_ref;
27017         CHECK(real_node_pubkey_arg->arr_len == 33);
27018         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
27019         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
27020         uint64_t ret_ref = 0;
27021         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27022         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27023         return ret_ref;
27024 }
27025
27026 static inline uint64_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
27027         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
27028         uint64_t ret_ref = 0;
27029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27030         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27031         return ret_ref;
27032 }
27033 int64_t  __attribute__((export_name("TS_PhantomRouteHints_clone_ptr"))) TS_PhantomRouteHints_clone_ptr(uint64_t arg) {
27034         LDKPhantomRouteHints arg_conv;
27035         arg_conv.inner = untag_ptr(arg);
27036         arg_conv.is_owned = ptr_is_owned(arg);
27037         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27038         arg_conv.is_owned = false;
27039         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
27040         return ret_conv;
27041 }
27042
27043 uint64_t  __attribute__((export_name("TS_PhantomRouteHints_clone"))) TS_PhantomRouteHints_clone(uint64_t orig) {
27044         LDKPhantomRouteHints orig_conv;
27045         orig_conv.inner = untag_ptr(orig);
27046         orig_conv.is_owned = ptr_is_owned(orig);
27047         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27048         orig_conv.is_owned = false;
27049         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
27050         uint64_t ret_ref = 0;
27051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27052         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27053         return ret_ref;
27054 }
27055
27056 uint64_t  __attribute__((export_name("TS_ChannelManager_new"))) TS_ChannelManager_new(uint64_t fee_est, uint64_t chain_monitor, uint64_t tx_broadcaster, uint64_t logger, uint64_t keys_manager, uint64_t config, uint64_t params) {
27057         void* fee_est_ptr = untag_ptr(fee_est);
27058         CHECK_ACCESS(fee_est_ptr);
27059         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
27060         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
27061                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27062                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
27063         }
27064         void* chain_monitor_ptr = untag_ptr(chain_monitor);
27065         CHECK_ACCESS(chain_monitor_ptr);
27066         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
27067         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
27068                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27069                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
27070         }
27071         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
27072         CHECK_ACCESS(tx_broadcaster_ptr);
27073         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
27074         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27075                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27076                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
27077         }
27078         void* logger_ptr = untag_ptr(logger);
27079         CHECK_ACCESS(logger_ptr);
27080         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27081         if (logger_conv.free == LDKLogger_JCalls_free) {
27082                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27083                 LDKLogger_JCalls_cloned(&logger_conv);
27084         }
27085         void* keys_manager_ptr = untag_ptr(keys_manager);
27086         CHECK_ACCESS(keys_manager_ptr);
27087         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
27088         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
27089                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27090                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
27091         }
27092         LDKUserConfig config_conv;
27093         config_conv.inner = untag_ptr(config);
27094         config_conv.is_owned = ptr_is_owned(config);
27095         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
27096         config_conv = UserConfig_clone(&config_conv);
27097         LDKChainParameters params_conv;
27098         params_conv.inner = untag_ptr(params);
27099         params_conv.is_owned = ptr_is_owned(params);
27100         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
27101         params_conv = ChainParameters_clone(&params_conv);
27102         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
27103         uint64_t ret_ref = 0;
27104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27105         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27106         return ret_ref;
27107 }
27108
27109 uint64_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint64_t this_arg) {
27110         LDKChannelManager this_arg_conv;
27111         this_arg_conv.inner = untag_ptr(this_arg);
27112         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27114         this_arg_conv.is_owned = false;
27115         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
27116         uint64_t ret_ref = 0;
27117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27118         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27119         return ret_ref;
27120 }
27121
27122 uint64_t  __attribute__((export_name("TS_ChannelManager_create_channel"))) TS_ChannelManager_create_channel(uint64_t this_arg, int8_tArray their_network_key, int64_t channel_value_satoshis, int64_t push_msat, int64_t user_channel_id, uint64_t override_config) {
27123         LDKChannelManager this_arg_conv;
27124         this_arg_conv.inner = untag_ptr(this_arg);
27125         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27127         this_arg_conv.is_owned = false;
27128         LDKPublicKey their_network_key_ref;
27129         CHECK(their_network_key->arr_len == 33);
27130         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
27131         LDKUserConfig override_config_conv;
27132         override_config_conv.inner = untag_ptr(override_config);
27133         override_config_conv.is_owned = ptr_is_owned(override_config);
27134         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
27135         override_config_conv = UserConfig_clone(&override_config_conv);
27136         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
27137         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
27138         return tag_ptr(ret_conv, true);
27139 }
27140
27141 uint64_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint64_t this_arg) {
27142         LDKChannelManager this_arg_conv;
27143         this_arg_conv.inner = untag_ptr(this_arg);
27144         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27146         this_arg_conv.is_owned = false;
27147         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
27148         uint64_tArray ret_arr = NULL;
27149         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
27150         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
27151         for (size_t q = 0; q < ret_var.datalen; q++) {
27152                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
27153                 uint64_t ret_conv_16_ref = 0;
27154                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
27155                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
27156                 ret_arr_ptr[q] = ret_conv_16_ref;
27157         }
27158         
27159         FREE(ret_var.data);
27160         return ret_arr;
27161 }
27162
27163 uint64_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint64_t this_arg) {
27164         LDKChannelManager this_arg_conv;
27165         this_arg_conv.inner = untag_ptr(this_arg);
27166         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27168         this_arg_conv.is_owned = false;
27169         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
27170         uint64_tArray ret_arr = NULL;
27171         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
27172         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
27173         for (size_t q = 0; q < ret_var.datalen; q++) {
27174                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
27175                 uint64_t ret_conv_16_ref = 0;
27176                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
27177                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
27178                 ret_arr_ptr[q] = ret_conv_16_ref;
27179         }
27180         
27181         FREE(ret_var.data);
27182         return ret_arr;
27183 }
27184
27185 uint64_t  __attribute__((export_name("TS_ChannelManager_close_channel"))) TS_ChannelManager_close_channel(uint64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
27186         LDKChannelManager this_arg_conv;
27187         this_arg_conv.inner = untag_ptr(this_arg);
27188         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27190         this_arg_conv.is_owned = false;
27191         unsigned char channel_id_arr[32];
27192         CHECK(channel_id->arr_len == 32);
27193         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27194         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27195         LDKPublicKey counterparty_node_id_ref;
27196         CHECK(counterparty_node_id->arr_len == 33);
27197         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27198         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27199         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
27200         return tag_ptr(ret_conv, true);
27201 }
27202
27203 uint64_t  __attribute__((export_name("TS_ChannelManager_close_channel_with_target_feerate"))) TS_ChannelManager_close_channel_with_target_feerate(uint64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id, int32_t target_feerate_sats_per_1000_weight) {
27204         LDKChannelManager this_arg_conv;
27205         this_arg_conv.inner = untag_ptr(this_arg);
27206         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27208         this_arg_conv.is_owned = false;
27209         unsigned char channel_id_arr[32];
27210         CHECK(channel_id->arr_len == 32);
27211         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27212         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27213         LDKPublicKey counterparty_node_id_ref;
27214         CHECK(counterparty_node_id->arr_len == 33);
27215         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27216         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27217         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
27218         return tag_ptr(ret_conv, true);
27219 }
27220
27221 uint64_t  __attribute__((export_name("TS_ChannelManager_force_close_broadcasting_latest_txn"))) TS_ChannelManager_force_close_broadcasting_latest_txn(uint64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
27222         LDKChannelManager this_arg_conv;
27223         this_arg_conv.inner = untag_ptr(this_arg);
27224         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27226         this_arg_conv.is_owned = false;
27227         unsigned char channel_id_arr[32];
27228         CHECK(channel_id->arr_len == 32);
27229         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27230         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27231         LDKPublicKey counterparty_node_id_ref;
27232         CHECK(counterparty_node_id->arr_len == 33);
27233         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27234         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27235         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
27236         return tag_ptr(ret_conv, true);
27237 }
27238
27239 uint64_t  __attribute__((export_name("TS_ChannelManager_force_close_without_broadcasting_txn"))) TS_ChannelManager_force_close_without_broadcasting_txn(uint64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
27240         LDKChannelManager this_arg_conv;
27241         this_arg_conv.inner = untag_ptr(this_arg);
27242         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27244         this_arg_conv.is_owned = false;
27245         unsigned char channel_id_arr[32];
27246         CHECK(channel_id->arr_len == 32);
27247         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27248         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27249         LDKPublicKey counterparty_node_id_ref;
27250         CHECK(counterparty_node_id->arr_len == 33);
27251         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27252         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27253         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
27254         return tag_ptr(ret_conv, true);
27255 }
27256
27257 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels_broadcasting_latest_txn"))) TS_ChannelManager_force_close_all_channels_broadcasting_latest_txn(uint64_t this_arg) {
27258         LDKChannelManager this_arg_conv;
27259         this_arg_conv.inner = untag_ptr(this_arg);
27260         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27262         this_arg_conv.is_owned = false;
27263         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
27264 }
27265
27266 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels_without_broadcasting_txn"))) TS_ChannelManager_force_close_all_channels_without_broadcasting_txn(uint64_t this_arg) {
27267         LDKChannelManager this_arg_conv;
27268         this_arg_conv.inner = untag_ptr(this_arg);
27269         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27271         this_arg_conv.is_owned = false;
27272         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
27273 }
27274
27275 uint64_t  __attribute__((export_name("TS_ChannelManager_send_payment"))) TS_ChannelManager_send_payment(uint64_t this_arg, uint64_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
27276         LDKChannelManager this_arg_conv;
27277         this_arg_conv.inner = untag_ptr(this_arg);
27278         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27280         this_arg_conv.is_owned = false;
27281         LDKRoute route_conv;
27282         route_conv.inner = untag_ptr(route);
27283         route_conv.is_owned = ptr_is_owned(route);
27284         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27285         route_conv.is_owned = false;
27286         LDKThirtyTwoBytes payment_hash_ref;
27287         CHECK(payment_hash->arr_len == 32);
27288         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27289         LDKThirtyTwoBytes payment_secret_ref;
27290         CHECK(payment_secret->arr_len == 32);
27291         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
27292         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
27293         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
27294         return tag_ptr(ret_conv, true);
27295 }
27296
27297 uint64_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint64_t this_arg, uint64_t route, int8_tArray payment_id) {
27298         LDKChannelManager this_arg_conv;
27299         this_arg_conv.inner = untag_ptr(this_arg);
27300         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27302         this_arg_conv.is_owned = false;
27303         LDKRoute route_conv;
27304         route_conv.inner = untag_ptr(route);
27305         route_conv.is_owned = ptr_is_owned(route);
27306         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27307         route_conv.is_owned = false;
27308         LDKThirtyTwoBytes payment_id_ref;
27309         CHECK(payment_id->arr_len == 32);
27310         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
27311         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
27312         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
27313         return tag_ptr(ret_conv, true);
27314 }
27315
27316 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint64_t this_arg, int8_tArray payment_id) {
27317         LDKChannelManager this_arg_conv;
27318         this_arg_conv.inner = untag_ptr(this_arg);
27319         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27321         this_arg_conv.is_owned = false;
27322         LDKThirtyTwoBytes payment_id_ref;
27323         CHECK(payment_id->arr_len == 32);
27324         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
27325         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
27326 }
27327
27328 uint64_t  __attribute__((export_name("TS_ChannelManager_send_spontaneous_payment"))) TS_ChannelManager_send_spontaneous_payment(uint64_t this_arg, uint64_t route, int8_tArray payment_preimage) {
27329         LDKChannelManager this_arg_conv;
27330         this_arg_conv.inner = untag_ptr(this_arg);
27331         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27333         this_arg_conv.is_owned = false;
27334         LDKRoute route_conv;
27335         route_conv.inner = untag_ptr(route);
27336         route_conv.is_owned = ptr_is_owned(route);
27337         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27338         route_conv.is_owned = false;
27339         LDKThirtyTwoBytes payment_preimage_ref;
27340         CHECK(payment_preimage->arr_len == 32);
27341         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
27342         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
27343         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
27344         return tag_ptr(ret_conv, true);
27345 }
27346
27347 uint64_t  __attribute__((export_name("TS_ChannelManager_send_probe"))) TS_ChannelManager_send_probe(uint64_t this_arg, uint64_tArray hops) {
27348         LDKChannelManager this_arg_conv;
27349         this_arg_conv.inner = untag_ptr(this_arg);
27350         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27352         this_arg_conv.is_owned = false;
27353         LDKCVec_RouteHopZ hops_constr;
27354         hops_constr.datalen = hops->arr_len;
27355         if (hops_constr.datalen > 0)
27356                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
27357         else
27358                 hops_constr.data = NULL;
27359         uint64_t* hops_vals = hops->elems;
27360         for (size_t k = 0; k < hops_constr.datalen; k++) {
27361                 uint64_t hops_conv_10 = hops_vals[k];
27362                 LDKRouteHop hops_conv_10_conv;
27363                 hops_conv_10_conv.inner = untag_ptr(hops_conv_10);
27364                 hops_conv_10_conv.is_owned = ptr_is_owned(hops_conv_10);
27365                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
27366                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
27367                 hops_constr.data[k] = hops_conv_10_conv;
27368         }
27369         FREE(hops);
27370         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
27371         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
27372         return tag_ptr(ret_conv, true);
27373 }
27374
27375 uint64_t  __attribute__((export_name("TS_ChannelManager_funding_transaction_generated"))) TS_ChannelManager_funding_transaction_generated(uint64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int8_tArray funding_transaction) {
27376         LDKChannelManager this_arg_conv;
27377         this_arg_conv.inner = untag_ptr(this_arg);
27378         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27380         this_arg_conv.is_owned = false;
27381         unsigned char temporary_channel_id_arr[32];
27382         CHECK(temporary_channel_id->arr_len == 32);
27383         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
27384         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
27385         LDKPublicKey counterparty_node_id_ref;
27386         CHECK(counterparty_node_id->arr_len == 33);
27387         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27388         LDKTransaction funding_transaction_ref;
27389         funding_transaction_ref.datalen = funding_transaction->arr_len;
27390         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
27391         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
27392         funding_transaction_ref.data_is_owned = true;
27393         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27394         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
27395         return tag_ptr(ret_conv, true);
27396 }
27397
27398 uint64_t  __attribute__((export_name("TS_ChannelManager_update_channel_config"))) TS_ChannelManager_update_channel_config(uint64_t this_arg, int8_tArray counterparty_node_id, ptrArray channel_ids, uint64_t config) {
27399         LDKChannelManager this_arg_conv;
27400         this_arg_conv.inner = untag_ptr(this_arg);
27401         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27403         this_arg_conv.is_owned = false;
27404         LDKPublicKey counterparty_node_id_ref;
27405         CHECK(counterparty_node_id->arr_len == 33);
27406         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27407         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
27408         channel_ids_constr.datalen = channel_ids->arr_len;
27409         if (channel_ids_constr.datalen > 0)
27410                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
27411         else
27412                 channel_ids_constr.data = NULL;
27413         int8_tArray* channel_ids_vals = (void*) channel_ids->elems;
27414         for (size_t m = 0; m < channel_ids_constr.datalen; m++) {
27415                 int8_tArray channel_ids_conv_12 = channel_ids_vals[m];
27416                 LDKThirtyTwoBytes channel_ids_conv_12_ref;
27417                 CHECK(channel_ids_conv_12->arr_len == 32);
27418                 memcpy(channel_ids_conv_12_ref.data, channel_ids_conv_12->elems, 32); FREE(channel_ids_conv_12);
27419                 channel_ids_constr.data[m] = channel_ids_conv_12_ref;
27420         }
27421         FREE(channel_ids);
27422         LDKChannelConfig config_conv;
27423         config_conv.inner = untag_ptr(config);
27424         config_conv.is_owned = ptr_is_owned(config);
27425         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
27426         config_conv.is_owned = false;
27427         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27428         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
27429         return tag_ptr(ret_conv, true);
27430 }
27431
27432 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint64_t this_arg) {
27433         LDKChannelManager this_arg_conv;
27434         this_arg_conv.inner = untag_ptr(this_arg);
27435         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27437         this_arg_conv.is_owned = false;
27438         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
27439 }
27440
27441 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint64_t this_arg) {
27442         LDKChannelManager this_arg_conv;
27443         this_arg_conv.inner = untag_ptr(this_arg);
27444         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27446         this_arg_conv.is_owned = false;
27447         ChannelManager_timer_tick_occurred(&this_arg_conv);
27448 }
27449
27450 void  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint64_t this_arg, int8_tArray payment_hash) {
27451         LDKChannelManager this_arg_conv;
27452         this_arg_conv.inner = untag_ptr(this_arg);
27453         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27455         this_arg_conv.is_owned = false;
27456         unsigned char payment_hash_arr[32];
27457         CHECK(payment_hash->arr_len == 32);
27458         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
27459         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
27460         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
27461 }
27462
27463 void  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint64_t this_arg, int8_tArray payment_preimage) {
27464         LDKChannelManager this_arg_conv;
27465         this_arg_conv.inner = untag_ptr(this_arg);
27466         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27468         this_arg_conv.is_owned = false;
27469         LDKThirtyTwoBytes payment_preimage_ref;
27470         CHECK(payment_preimage->arr_len == 32);
27471         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
27472         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
27473 }
27474
27475 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint64_t this_arg) {
27476         LDKChannelManager this_arg_conv;
27477         this_arg_conv.inner = untag_ptr(this_arg);
27478         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27480         this_arg_conv.is_owned = false;
27481         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27482         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
27483         return ret_arr;
27484 }
27485
27486 uint64_t  __attribute__((export_name("TS_ChannelManager_accept_inbound_channel"))) TS_ChannelManager_accept_inbound_channel(uint64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
27487         LDKChannelManager this_arg_conv;
27488         this_arg_conv.inner = untag_ptr(this_arg);
27489         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27491         this_arg_conv.is_owned = false;
27492         unsigned char temporary_channel_id_arr[32];
27493         CHECK(temporary_channel_id->arr_len == 32);
27494         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
27495         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
27496         LDKPublicKey counterparty_node_id_ref;
27497         CHECK(counterparty_node_id->arr_len == 33);
27498         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27499         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27500         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
27501         return tag_ptr(ret_conv, true);
27502 }
27503
27504 uint64_t  __attribute__((export_name("TS_ChannelManager_accept_inbound_channel_from_trusted_peer_0conf"))) TS_ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(uint64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
27505         LDKChannelManager this_arg_conv;
27506         this_arg_conv.inner = untag_ptr(this_arg);
27507         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27509         this_arg_conv.is_owned = false;
27510         unsigned char temporary_channel_id_arr[32];
27511         CHECK(temporary_channel_id->arr_len == 32);
27512         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
27513         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
27514         LDKPublicKey counterparty_node_id_ref;
27515         CHECK(counterparty_node_id->arr_len == 33);
27516         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27517         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27518         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
27519         return tag_ptr(ret_conv, true);
27520 }
27521
27522 uint64_t  __attribute__((export_name("TS_ChannelManager_create_inbound_payment"))) TS_ChannelManager_create_inbound_payment(uint64_t this_arg, uint64_t min_value_msat, int32_t invoice_expiry_delta_secs) {
27523         LDKChannelManager this_arg_conv;
27524         this_arg_conv.inner = untag_ptr(this_arg);
27525         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27527         this_arg_conv.is_owned = false;
27528         void* min_value_msat_ptr = untag_ptr(min_value_msat);
27529         CHECK_ACCESS(min_value_msat_ptr);
27530         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27531         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
27532         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
27533         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
27534         return tag_ptr(ret_conv, true);
27535 }
27536
27537 uint64_t  __attribute__((export_name("TS_ChannelManager_create_inbound_payment_legacy"))) TS_ChannelManager_create_inbound_payment_legacy(uint64_t this_arg, uint64_t min_value_msat, int32_t invoice_expiry_delta_secs) {
27538         LDKChannelManager this_arg_conv;
27539         this_arg_conv.inner = untag_ptr(this_arg);
27540         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27542         this_arg_conv.is_owned = false;
27543         void* min_value_msat_ptr = untag_ptr(min_value_msat);
27544         CHECK_ACCESS(min_value_msat_ptr);
27545         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27546         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
27547         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
27548         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
27549         return tag_ptr(ret_conv, true);
27550 }
27551
27552 uint64_t  __attribute__((export_name("TS_ChannelManager_create_inbound_payment_for_hash"))) TS_ChannelManager_create_inbound_payment_for_hash(uint64_t this_arg, int8_tArray payment_hash, uint64_t min_value_msat, int32_t invoice_expiry_delta_secs) {
27553         LDKChannelManager this_arg_conv;
27554         this_arg_conv.inner = untag_ptr(this_arg);
27555         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27557         this_arg_conv.is_owned = false;
27558         LDKThirtyTwoBytes payment_hash_ref;
27559         CHECK(payment_hash->arr_len == 32);
27560         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27561         void* min_value_msat_ptr = untag_ptr(min_value_msat);
27562         CHECK_ACCESS(min_value_msat_ptr);
27563         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27564         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
27565         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
27566         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
27567         return tag_ptr(ret_conv, true);
27568 }
27569
27570 uint64_t  __attribute__((export_name("TS_ChannelManager_create_inbound_payment_for_hash_legacy"))) TS_ChannelManager_create_inbound_payment_for_hash_legacy(uint64_t this_arg, int8_tArray payment_hash, uint64_t min_value_msat, int32_t invoice_expiry_delta_secs) {
27571         LDKChannelManager this_arg_conv;
27572         this_arg_conv.inner = untag_ptr(this_arg);
27573         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27575         this_arg_conv.is_owned = false;
27576         LDKThirtyTwoBytes payment_hash_ref;
27577         CHECK(payment_hash->arr_len == 32);
27578         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27579         void* min_value_msat_ptr = untag_ptr(min_value_msat);
27580         CHECK_ACCESS(min_value_msat_ptr);
27581         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27582         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
27583         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
27584         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
27585         return tag_ptr(ret_conv, true);
27586 }
27587
27588 uint64_t  __attribute__((export_name("TS_ChannelManager_get_payment_preimage"))) TS_ChannelManager_get_payment_preimage(uint64_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
27589         LDKChannelManager this_arg_conv;
27590         this_arg_conv.inner = untag_ptr(this_arg);
27591         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27593         this_arg_conv.is_owned = false;
27594         LDKThirtyTwoBytes payment_hash_ref;
27595         CHECK(payment_hash->arr_len == 32);
27596         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27597         LDKThirtyTwoBytes payment_secret_ref;
27598         CHECK(payment_secret->arr_len == 32);
27599         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
27600         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
27601         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
27602         return tag_ptr(ret_conv, true);
27603 }
27604
27605 int64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_scid"))) TS_ChannelManager_get_phantom_scid(uint64_t this_arg) {
27606         LDKChannelManager this_arg_conv;
27607         this_arg_conv.inner = untag_ptr(this_arg);
27608         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27610         this_arg_conv.is_owned = false;
27611         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
27612         return ret_conv;
27613 }
27614
27615 uint64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_route_hints"))) TS_ChannelManager_get_phantom_route_hints(uint64_t this_arg) {
27616         LDKChannelManager this_arg_conv;
27617         this_arg_conv.inner = untag_ptr(this_arg);
27618         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27620         this_arg_conv.is_owned = false;
27621         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
27622         uint64_t ret_ref = 0;
27623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27624         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27625         return ret_ref;
27626 }
27627
27628 uint64_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint64_t this_arg) {
27629         LDKChannelManager this_arg_conv;
27630         this_arg_conv.inner = untag_ptr(this_arg);
27631         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27633         this_arg_conv.is_owned = false;
27634         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
27635         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
27636         return tag_ptr(ret_ret, true);
27637 }
27638
27639 uint64_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint64_t this_arg) {
27640         LDKChannelManager this_arg_conv;
27641         this_arg_conv.inner = untag_ptr(this_arg);
27642         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27644         this_arg_conv.is_owned = false;
27645         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
27646         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
27647         return tag_ptr(ret_ret, true);
27648 }
27649
27650 uint64_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint64_t this_arg) {
27651         LDKChannelManager this_arg_conv;
27652         this_arg_conv.inner = untag_ptr(this_arg);
27653         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27655         this_arg_conv.is_owned = false;
27656         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
27657         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
27658         return tag_ptr(ret_ret, true);
27659 }
27660
27661 uint64_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint64_t this_arg) {
27662         LDKChannelManager this_arg_conv;
27663         this_arg_conv.inner = untag_ptr(this_arg);
27664         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27666         this_arg_conv.is_owned = false;
27667         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
27668         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
27669         return tag_ptr(ret_ret, true);
27670 }
27671
27672 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint64_t this_arg) {
27673         LDKChannelManager this_arg_conv;
27674         this_arg_conv.inner = untag_ptr(this_arg);
27675         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27677         this_arg_conv.is_owned = false;
27678         ChannelManager_await_persistable_update(&this_arg_conv);
27679 }
27680
27681 uint64_t  __attribute__((export_name("TS_ChannelManager_get_persistable_update_future"))) TS_ChannelManager_get_persistable_update_future(uint64_t this_arg) {
27682         LDKChannelManager this_arg_conv;
27683         this_arg_conv.inner = untag_ptr(this_arg);
27684         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27686         this_arg_conv.is_owned = false;
27687         LDKFuture ret_var = ChannelManager_get_persistable_update_future(&this_arg_conv);
27688         uint64_t ret_ref = 0;
27689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27690         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27691         return ret_ref;
27692 }
27693
27694 uint64_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint64_t this_arg) {
27695         LDKChannelManager this_arg_conv;
27696         this_arg_conv.inner = untag_ptr(this_arg);
27697         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27699         this_arg_conv.is_owned = false;
27700         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
27701         uint64_t ret_ref = 0;
27702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27703         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27704         return ret_ref;
27705 }
27706
27707 uint64_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint64_t this_arg) {
27708         LDKChannelManager this_arg_conv;
27709         this_arg_conv.inner = untag_ptr(this_arg);
27710         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27712         this_arg_conv.is_owned = false;
27713         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
27714         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
27715         return tag_ptr(ret_ret, true);
27716 }
27717
27718 int8_tArray  __attribute__((export_name("TS_CounterpartyForwardingInfo_write"))) TS_CounterpartyForwardingInfo_write(uint64_t obj) {
27719         LDKCounterpartyForwardingInfo obj_conv;
27720         obj_conv.inner = untag_ptr(obj);
27721         obj_conv.is_owned = ptr_is_owned(obj);
27722         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27723         obj_conv.is_owned = false;
27724         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
27725         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27726         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27727         CVec_u8Z_free(ret_var);
27728         return ret_arr;
27729 }
27730
27731 uint64_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_read"))) TS_CounterpartyForwardingInfo_read(int8_tArray ser) {
27732         LDKu8slice ser_ref;
27733         ser_ref.datalen = ser->arr_len;
27734         ser_ref.data = ser->elems;
27735         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
27736         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
27737         FREE(ser);
27738         return tag_ptr(ret_conv, true);
27739 }
27740
27741 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_write"))) TS_ChannelCounterparty_write(uint64_t obj) {
27742         LDKChannelCounterparty obj_conv;
27743         obj_conv.inner = untag_ptr(obj);
27744         obj_conv.is_owned = ptr_is_owned(obj);
27745         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27746         obj_conv.is_owned = false;
27747         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
27748         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27749         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27750         CVec_u8Z_free(ret_var);
27751         return ret_arr;
27752 }
27753
27754 uint64_t  __attribute__((export_name("TS_ChannelCounterparty_read"))) TS_ChannelCounterparty_read(int8_tArray ser) {
27755         LDKu8slice ser_ref;
27756         ser_ref.datalen = ser->arr_len;
27757         ser_ref.data = ser->elems;
27758         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
27759         *ret_conv = ChannelCounterparty_read(ser_ref);
27760         FREE(ser);
27761         return tag_ptr(ret_conv, true);
27762 }
27763
27764 int8_tArray  __attribute__((export_name("TS_ChannelDetails_write"))) TS_ChannelDetails_write(uint64_t obj) {
27765         LDKChannelDetails obj_conv;
27766         obj_conv.inner = untag_ptr(obj);
27767         obj_conv.is_owned = ptr_is_owned(obj);
27768         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27769         obj_conv.is_owned = false;
27770         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
27771         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27772         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27773         CVec_u8Z_free(ret_var);
27774         return ret_arr;
27775 }
27776
27777 uint64_t  __attribute__((export_name("TS_ChannelDetails_read"))) TS_ChannelDetails_read(int8_tArray ser) {
27778         LDKu8slice ser_ref;
27779         ser_ref.datalen = ser->arr_len;
27780         ser_ref.data = ser->elems;
27781         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
27782         *ret_conv = ChannelDetails_read(ser_ref);
27783         FREE(ser);
27784         return tag_ptr(ret_conv, true);
27785 }
27786
27787 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_write"))) TS_PhantomRouteHints_write(uint64_t obj) {
27788         LDKPhantomRouteHints obj_conv;
27789         obj_conv.inner = untag_ptr(obj);
27790         obj_conv.is_owned = ptr_is_owned(obj);
27791         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27792         obj_conv.is_owned = false;
27793         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
27794         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27795         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27796         CVec_u8Z_free(ret_var);
27797         return ret_arr;
27798 }
27799
27800 uint64_t  __attribute__((export_name("TS_PhantomRouteHints_read"))) TS_PhantomRouteHints_read(int8_tArray ser) {
27801         LDKu8slice ser_ref;
27802         ser_ref.datalen = ser->arr_len;
27803         ser_ref.data = ser->elems;
27804         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
27805         *ret_conv = PhantomRouteHints_read(ser_ref);
27806         FREE(ser);
27807         return tag_ptr(ret_conv, true);
27808 }
27809
27810 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint64_t obj) {
27811         LDKChannelManager obj_conv;
27812         obj_conv.inner = untag_ptr(obj);
27813         obj_conv.is_owned = ptr_is_owned(obj);
27814         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27815         obj_conv.is_owned = false;
27816         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
27817         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27818         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27819         CVec_u8Z_free(ret_var);
27820         return ret_arr;
27821 }
27822
27823 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint64_t this_obj) {
27824         LDKChannelManagerReadArgs this_obj_conv;
27825         this_obj_conv.inner = untag_ptr(this_obj);
27826         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27828         ChannelManagerReadArgs_free(this_obj_conv);
27829 }
27830
27831 uint64_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint64_t this_ptr) {
27832         LDKChannelManagerReadArgs this_ptr_conv;
27833         this_ptr_conv.inner = untag_ptr(this_ptr);
27834         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27836         this_ptr_conv.is_owned = false;
27837         // WARNING: This object doesn't live past this scope, needs clone!
27838         uint64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv), false);
27839         return ret_ret;
27840 }
27841
27842 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint64_t this_ptr, uint64_t val) {
27843         LDKChannelManagerReadArgs this_ptr_conv;
27844         this_ptr_conv.inner = untag_ptr(this_ptr);
27845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27847         this_ptr_conv.is_owned = false;
27848         void* val_ptr = untag_ptr(val);
27849         CHECK_ACCESS(val_ptr);
27850         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
27851         if (val_conv.free == LDKKeysInterface_JCalls_free) {
27852                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27853                 LDKKeysInterface_JCalls_cloned(&val_conv);
27854         }
27855         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
27856 }
27857
27858 uint64_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint64_t this_ptr) {
27859         LDKChannelManagerReadArgs this_ptr_conv;
27860         this_ptr_conv.inner = untag_ptr(this_ptr);
27861         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27863         this_ptr_conv.is_owned = false;
27864         // WARNING: This object doesn't live past this scope, needs clone!
27865         uint64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv), false);
27866         return ret_ret;
27867 }
27868
27869 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint64_t this_ptr, uint64_t val) {
27870         LDKChannelManagerReadArgs this_ptr_conv;
27871         this_ptr_conv.inner = untag_ptr(this_ptr);
27872         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27874         this_ptr_conv.is_owned = false;
27875         void* val_ptr = untag_ptr(val);
27876         CHECK_ACCESS(val_ptr);
27877         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
27878         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
27879                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27880                 LDKFeeEstimator_JCalls_cloned(&val_conv);
27881         }
27882         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
27883 }
27884
27885 uint64_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint64_t this_ptr) {
27886         LDKChannelManagerReadArgs this_ptr_conv;
27887         this_ptr_conv.inner = untag_ptr(this_ptr);
27888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27890         this_ptr_conv.is_owned = false;
27891         // WARNING: This object doesn't live past this scope, needs clone!
27892         uint64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv), false);
27893         return ret_ret;
27894 }
27895
27896 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint64_t this_ptr, uint64_t val) {
27897         LDKChannelManagerReadArgs this_ptr_conv;
27898         this_ptr_conv.inner = untag_ptr(this_ptr);
27899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27901         this_ptr_conv.is_owned = false;
27902         void* val_ptr = untag_ptr(val);
27903         CHECK_ACCESS(val_ptr);
27904         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
27905         if (val_conv.free == LDKWatch_JCalls_free) {
27906                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27907                 LDKWatch_JCalls_cloned(&val_conv);
27908         }
27909         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
27910 }
27911
27912 uint64_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint64_t this_ptr) {
27913         LDKChannelManagerReadArgs this_ptr_conv;
27914         this_ptr_conv.inner = untag_ptr(this_ptr);
27915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27917         this_ptr_conv.is_owned = false;
27918         // WARNING: This object doesn't live past this scope, needs clone!
27919         uint64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv), false);
27920         return ret_ret;
27921 }
27922
27923 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint64_t this_ptr, uint64_t val) {
27924         LDKChannelManagerReadArgs this_ptr_conv;
27925         this_ptr_conv.inner = untag_ptr(this_ptr);
27926         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27928         this_ptr_conv.is_owned = false;
27929         void* val_ptr = untag_ptr(val);
27930         CHECK_ACCESS(val_ptr);
27931         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
27932         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
27933                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27934                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
27935         }
27936         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
27937 }
27938
27939 uint64_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint64_t this_ptr) {
27940         LDKChannelManagerReadArgs this_ptr_conv;
27941         this_ptr_conv.inner = untag_ptr(this_ptr);
27942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27944         this_ptr_conv.is_owned = false;
27945         // WARNING: This object doesn't live past this scope, needs clone!
27946         uint64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_logger(&this_ptr_conv), false);
27947         return ret_ret;
27948 }
27949
27950 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint64_t this_ptr, uint64_t val) {
27951         LDKChannelManagerReadArgs this_ptr_conv;
27952         this_ptr_conv.inner = untag_ptr(this_ptr);
27953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27955         this_ptr_conv.is_owned = false;
27956         void* val_ptr = untag_ptr(val);
27957         CHECK_ACCESS(val_ptr);
27958         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
27959         if (val_conv.free == LDKLogger_JCalls_free) {
27960                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27961                 LDKLogger_JCalls_cloned(&val_conv);
27962         }
27963         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
27964 }
27965
27966 uint64_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint64_t this_ptr) {
27967         LDKChannelManagerReadArgs this_ptr_conv;
27968         this_ptr_conv.inner = untag_ptr(this_ptr);
27969         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27971         this_ptr_conv.is_owned = false;
27972         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
27973         uint64_t ret_ref = 0;
27974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27975         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27976         return ret_ref;
27977 }
27978
27979 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint64_t this_ptr, uint64_t val) {
27980         LDKChannelManagerReadArgs this_ptr_conv;
27981         this_ptr_conv.inner = untag_ptr(this_ptr);
27982         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27984         this_ptr_conv.is_owned = false;
27985         LDKUserConfig val_conv;
27986         val_conv.inner = untag_ptr(val);
27987         val_conv.is_owned = ptr_is_owned(val);
27988         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27989         val_conv = UserConfig_clone(&val_conv);
27990         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
27991 }
27992
27993 uint64_t  __attribute__((export_name("TS_ChannelManagerReadArgs_new"))) TS_ChannelManagerReadArgs_new(uint64_t keys_manager, uint64_t fee_estimator, uint64_t chain_monitor, uint64_t tx_broadcaster, uint64_t logger, uint64_t default_config, uint64_tArray channel_monitors) {
27994         void* keys_manager_ptr = untag_ptr(keys_manager);
27995         CHECK_ACCESS(keys_manager_ptr);
27996         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
27997         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
27998                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27999                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
28000         }
28001         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28002         CHECK_ACCESS(fee_estimator_ptr);
28003         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28004         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28005                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28006                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28007         }
28008         void* chain_monitor_ptr = untag_ptr(chain_monitor);
28009         CHECK_ACCESS(chain_monitor_ptr);
28010         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
28011         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
28012                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28013                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
28014         }
28015         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
28016         CHECK_ACCESS(tx_broadcaster_ptr);
28017         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
28018         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28019                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28020                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
28021         }
28022         void* logger_ptr = untag_ptr(logger);
28023         CHECK_ACCESS(logger_ptr);
28024         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28025         if (logger_conv.free == LDKLogger_JCalls_free) {
28026                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28027                 LDKLogger_JCalls_cloned(&logger_conv);
28028         }
28029         LDKUserConfig default_config_conv;
28030         default_config_conv.inner = untag_ptr(default_config);
28031         default_config_conv.is_owned = ptr_is_owned(default_config);
28032         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
28033         default_config_conv = UserConfig_clone(&default_config_conv);
28034         LDKCVec_ChannelMonitorZ channel_monitors_constr;
28035         channel_monitors_constr.datalen = channel_monitors->arr_len;
28036         if (channel_monitors_constr.datalen > 0)
28037                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
28038         else
28039                 channel_monitors_constr.data = NULL;
28040         uint64_t* channel_monitors_vals = channel_monitors->elems;
28041         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
28042                 uint64_t channel_monitors_conv_16 = channel_monitors_vals[q];
28043                 LDKChannelMonitor channel_monitors_conv_16_conv;
28044                 channel_monitors_conv_16_conv.inner = untag_ptr(channel_monitors_conv_16);
28045                 channel_monitors_conv_16_conv.is_owned = ptr_is_owned(channel_monitors_conv_16);
28046                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
28047                 channel_monitors_conv_16_conv.is_owned = false;
28048                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
28049         }
28050         FREE(channel_monitors);
28051         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);
28052         uint64_t ret_ref = 0;
28053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28054         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28055         return ret_ref;
28056 }
28057
28058 uint64_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint64_t arg) {
28059         LDKu8slice ser_ref;
28060         ser_ref.datalen = ser->arr_len;
28061         ser_ref.data = ser->elems;
28062         LDKChannelManagerReadArgs arg_conv;
28063         arg_conv.inner = untag_ptr(arg);
28064         arg_conv.is_owned = ptr_is_owned(arg);
28065         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28066         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
28067         
28068         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
28069         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
28070         FREE(ser);
28071         return tag_ptr(ret_conv, true);
28072 }
28073
28074 void  __attribute__((export_name("TS_ExpandedKey_free"))) TS_ExpandedKey_free(uint64_t this_obj) {
28075         LDKExpandedKey this_obj_conv;
28076         this_obj_conv.inner = untag_ptr(this_obj);
28077         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28079         ExpandedKey_free(this_obj_conv);
28080 }
28081
28082 uint64_t  __attribute__((export_name("TS_ExpandedKey_new"))) TS_ExpandedKey_new(int8_tArray key_material) {
28083         unsigned char key_material_arr[32];
28084         CHECK(key_material->arr_len == 32);
28085         memcpy(key_material_arr, key_material->elems, 32); FREE(key_material);
28086         unsigned char (*key_material_ref)[32] = &key_material_arr;
28087         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
28088         uint64_t ret_ref = 0;
28089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28090         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28091         return ret_ref;
28092 }
28093
28094 uint64_t  __attribute__((export_name("TS_create"))) TS_create(uint64_t keys, uint64_t min_value_msat, int32_t invoice_expiry_delta_secs, uint64_t keys_manager, int64_t current_time) {
28095         LDKExpandedKey keys_conv;
28096         keys_conv.inner = untag_ptr(keys);
28097         keys_conv.is_owned = ptr_is_owned(keys);
28098         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
28099         keys_conv.is_owned = false;
28100         void* min_value_msat_ptr = untag_ptr(min_value_msat);
28101         CHECK_ACCESS(min_value_msat_ptr);
28102         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28103         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
28104         void* keys_manager_ptr = untag_ptr(keys_manager);
28105         if (ptr_is_owned(keys_manager)) { CHECK_ACCESS(keys_manager_ptr); }
28106         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
28107         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
28108         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
28109         return tag_ptr(ret_conv, true);
28110 }
28111
28112 uint64_t  __attribute__((export_name("TS_create_from_hash"))) TS_create_from_hash(uint64_t keys, uint64_t min_value_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t current_time) {
28113         LDKExpandedKey keys_conv;
28114         keys_conv.inner = untag_ptr(keys);
28115         keys_conv.is_owned = ptr_is_owned(keys);
28116         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
28117         keys_conv.is_owned = false;
28118         void* min_value_msat_ptr = untag_ptr(min_value_msat);
28119         CHECK_ACCESS(min_value_msat_ptr);
28120         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28121         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
28122         LDKThirtyTwoBytes payment_hash_ref;
28123         CHECK(payment_hash->arr_len == 32);
28124         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
28125         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
28126         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
28127         return tag_ptr(ret_conv, true);
28128 }
28129
28130 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint64_t this_obj) {
28131         LDKDecodeError this_obj_conv;
28132         this_obj_conv.inner = untag_ptr(this_obj);
28133         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28135         DecodeError_free(this_obj_conv);
28136 }
28137
28138 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
28139         LDKDecodeError ret_var = DecodeError_clone(arg);
28140         uint64_t ret_ref = 0;
28141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28142         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28143         return ret_ref;
28144 }
28145 int64_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint64_t arg) {
28146         LDKDecodeError arg_conv;
28147         arg_conv.inner = untag_ptr(arg);
28148         arg_conv.is_owned = ptr_is_owned(arg);
28149         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28150         arg_conv.is_owned = false;
28151         int64_t ret_conv = DecodeError_clone_ptr(&arg_conv);
28152         return ret_conv;
28153 }
28154
28155 uint64_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint64_t orig) {
28156         LDKDecodeError orig_conv;
28157         orig_conv.inner = untag_ptr(orig);
28158         orig_conv.is_owned = ptr_is_owned(orig);
28159         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28160         orig_conv.is_owned = false;
28161         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
28162         uint64_t ret_ref = 0;
28163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28164         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28165         return ret_ref;
28166 }
28167
28168 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint64_t this_obj) {
28169         LDKInit this_obj_conv;
28170         this_obj_conv.inner = untag_ptr(this_obj);
28171         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28173         Init_free(this_obj_conv);
28174 }
28175
28176 uint64_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint64_t this_ptr) {
28177         LDKInit this_ptr_conv;
28178         this_ptr_conv.inner = untag_ptr(this_ptr);
28179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28181         this_ptr_conv.is_owned = false;
28182         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
28183         uint64_t ret_ref = 0;
28184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28185         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28186         return ret_ref;
28187 }
28188
28189 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint64_t this_ptr, uint64_t val) {
28190         LDKInit this_ptr_conv;
28191         this_ptr_conv.inner = untag_ptr(this_ptr);
28192         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28194         this_ptr_conv.is_owned = false;
28195         LDKInitFeatures val_conv;
28196         val_conv.inner = untag_ptr(val);
28197         val_conv.is_owned = ptr_is_owned(val);
28198         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28199         val_conv = InitFeatures_clone(&val_conv);
28200         Init_set_features(&this_ptr_conv, val_conv);
28201 }
28202
28203 uint64_t  __attribute__((export_name("TS_Init_get_remote_network_address"))) TS_Init_get_remote_network_address(uint64_t this_ptr) {
28204         LDKInit this_ptr_conv;
28205         this_ptr_conv.inner = untag_ptr(this_ptr);
28206         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28208         this_ptr_conv.is_owned = false;
28209         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
28210         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
28211         uint64_t ret_ref = tag_ptr(ret_copy, true);
28212         return ret_ref;
28213 }
28214
28215 void  __attribute__((export_name("TS_Init_set_remote_network_address"))) TS_Init_set_remote_network_address(uint64_t this_ptr, uint64_t val) {
28216         LDKInit this_ptr_conv;
28217         this_ptr_conv.inner = untag_ptr(this_ptr);
28218         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28220         this_ptr_conv.is_owned = false;
28221         void* val_ptr = untag_ptr(val);
28222         CHECK_ACCESS(val_ptr);
28223         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
28224         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(val));
28225         Init_set_remote_network_address(&this_ptr_conv, val_conv);
28226 }
28227
28228 uint64_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint64_t features_arg, uint64_t remote_network_address_arg) {
28229         LDKInitFeatures features_arg_conv;
28230         features_arg_conv.inner = untag_ptr(features_arg);
28231         features_arg_conv.is_owned = ptr_is_owned(features_arg);
28232         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
28233         features_arg_conv = InitFeatures_clone(&features_arg_conv);
28234         void* remote_network_address_arg_ptr = untag_ptr(remote_network_address_arg);
28235         CHECK_ACCESS(remote_network_address_arg_ptr);
28236         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
28237         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
28238         uint64_t ret_ref = 0;
28239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28240         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28241         return ret_ref;
28242 }
28243
28244 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
28245         LDKInit ret_var = Init_clone(arg);
28246         uint64_t ret_ref = 0;
28247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28248         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28249         return ret_ref;
28250 }
28251 int64_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint64_t arg) {
28252         LDKInit arg_conv;
28253         arg_conv.inner = untag_ptr(arg);
28254         arg_conv.is_owned = ptr_is_owned(arg);
28255         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28256         arg_conv.is_owned = false;
28257         int64_t ret_conv = Init_clone_ptr(&arg_conv);
28258         return ret_conv;
28259 }
28260
28261 uint64_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint64_t orig) {
28262         LDKInit orig_conv;
28263         orig_conv.inner = untag_ptr(orig);
28264         orig_conv.is_owned = ptr_is_owned(orig);
28265         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28266         orig_conv.is_owned = false;
28267         LDKInit ret_var = Init_clone(&orig_conv);
28268         uint64_t ret_ref = 0;
28269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28270         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28271         return ret_ref;
28272 }
28273
28274 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint64_t this_obj) {
28275         LDKErrorMessage this_obj_conv;
28276         this_obj_conv.inner = untag_ptr(this_obj);
28277         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28279         ErrorMessage_free(this_obj_conv);
28280 }
28281
28282 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint64_t this_ptr) {
28283         LDKErrorMessage this_ptr_conv;
28284         this_ptr_conv.inner = untag_ptr(this_ptr);
28285         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28287         this_ptr_conv.is_owned = false;
28288         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28289         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
28290         return ret_arr;
28291 }
28292
28293 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint64_t this_ptr, int8_tArray val) {
28294         LDKErrorMessage this_ptr_conv;
28295         this_ptr_conv.inner = untag_ptr(this_ptr);
28296         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28298         this_ptr_conv.is_owned = false;
28299         LDKThirtyTwoBytes val_ref;
28300         CHECK(val->arr_len == 32);
28301         memcpy(val_ref.data, val->elems, 32); FREE(val);
28302         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
28303 }
28304
28305 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint64_t this_ptr) {
28306         LDKErrorMessage this_ptr_conv;
28307         this_ptr_conv.inner = untag_ptr(this_ptr);
28308         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28310         this_ptr_conv.is_owned = false;
28311         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
28312         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
28313         Str_free(ret_str);
28314         return ret_conv;
28315 }
28316
28317 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint64_t this_ptr, jstring val) {
28318         LDKErrorMessage this_ptr_conv;
28319         this_ptr_conv.inner = untag_ptr(this_ptr);
28320         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28322         this_ptr_conv.is_owned = false;
28323         LDKStr val_conv = str_ref_to_owned_c(val);
28324         ErrorMessage_set_data(&this_ptr_conv, val_conv);
28325 }
28326
28327 uint64_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
28328         LDKThirtyTwoBytes channel_id_arg_ref;
28329         CHECK(channel_id_arg->arr_len == 32);
28330         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28331         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
28332         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
28333         uint64_t ret_ref = 0;
28334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28335         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28336         return ret_ref;
28337 }
28338
28339 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
28340         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
28341         uint64_t ret_ref = 0;
28342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28343         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28344         return ret_ref;
28345 }
28346 int64_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint64_t arg) {
28347         LDKErrorMessage arg_conv;
28348         arg_conv.inner = untag_ptr(arg);
28349         arg_conv.is_owned = ptr_is_owned(arg);
28350         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28351         arg_conv.is_owned = false;
28352         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
28353         return ret_conv;
28354 }
28355
28356 uint64_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint64_t orig) {
28357         LDKErrorMessage orig_conv;
28358         orig_conv.inner = untag_ptr(orig);
28359         orig_conv.is_owned = ptr_is_owned(orig);
28360         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28361         orig_conv.is_owned = false;
28362         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
28363         uint64_t ret_ref = 0;
28364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28366         return ret_ref;
28367 }
28368
28369 void  __attribute__((export_name("TS_WarningMessage_free"))) TS_WarningMessage_free(uint64_t this_obj) {
28370         LDKWarningMessage this_obj_conv;
28371         this_obj_conv.inner = untag_ptr(this_obj);
28372         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28374         WarningMessage_free(this_obj_conv);
28375 }
28376
28377 int8_tArray  __attribute__((export_name("TS_WarningMessage_get_channel_id"))) TS_WarningMessage_get_channel_id(uint64_t this_ptr) {
28378         LDKWarningMessage this_ptr_conv;
28379         this_ptr_conv.inner = untag_ptr(this_ptr);
28380         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28382         this_ptr_conv.is_owned = false;
28383         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28384         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
28385         return ret_arr;
28386 }
28387
28388 void  __attribute__((export_name("TS_WarningMessage_set_channel_id"))) TS_WarningMessage_set_channel_id(uint64_t this_ptr, int8_tArray val) {
28389         LDKWarningMessage this_ptr_conv;
28390         this_ptr_conv.inner = untag_ptr(this_ptr);
28391         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28393         this_ptr_conv.is_owned = false;
28394         LDKThirtyTwoBytes val_ref;
28395         CHECK(val->arr_len == 32);
28396         memcpy(val_ref.data, val->elems, 32); FREE(val);
28397         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
28398 }
28399
28400 jstring  __attribute__((export_name("TS_WarningMessage_get_data"))) TS_WarningMessage_get_data(uint64_t this_ptr) {
28401         LDKWarningMessage this_ptr_conv;
28402         this_ptr_conv.inner = untag_ptr(this_ptr);
28403         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28405         this_ptr_conv.is_owned = false;
28406         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
28407         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
28408         Str_free(ret_str);
28409         return ret_conv;
28410 }
28411
28412 void  __attribute__((export_name("TS_WarningMessage_set_data"))) TS_WarningMessage_set_data(uint64_t this_ptr, jstring val) {
28413         LDKWarningMessage this_ptr_conv;
28414         this_ptr_conv.inner = untag_ptr(this_ptr);
28415         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28417         this_ptr_conv.is_owned = false;
28418         LDKStr val_conv = str_ref_to_owned_c(val);
28419         WarningMessage_set_data(&this_ptr_conv, val_conv);
28420 }
28421
28422 uint64_t  __attribute__((export_name("TS_WarningMessage_new"))) TS_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
28423         LDKThirtyTwoBytes channel_id_arg_ref;
28424         CHECK(channel_id_arg->arr_len == 32);
28425         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28426         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
28427         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
28428         uint64_t ret_ref = 0;
28429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28430         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28431         return ret_ref;
28432 }
28433
28434 static inline uint64_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
28435         LDKWarningMessage ret_var = WarningMessage_clone(arg);
28436         uint64_t ret_ref = 0;
28437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28438         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28439         return ret_ref;
28440 }
28441 int64_t  __attribute__((export_name("TS_WarningMessage_clone_ptr"))) TS_WarningMessage_clone_ptr(uint64_t arg) {
28442         LDKWarningMessage arg_conv;
28443         arg_conv.inner = untag_ptr(arg);
28444         arg_conv.is_owned = ptr_is_owned(arg);
28445         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28446         arg_conv.is_owned = false;
28447         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
28448         return ret_conv;
28449 }
28450
28451 uint64_t  __attribute__((export_name("TS_WarningMessage_clone"))) TS_WarningMessage_clone(uint64_t orig) {
28452         LDKWarningMessage orig_conv;
28453         orig_conv.inner = untag_ptr(orig);
28454         orig_conv.is_owned = ptr_is_owned(orig);
28455         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28456         orig_conv.is_owned = false;
28457         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
28458         uint64_t ret_ref = 0;
28459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28460         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28461         return ret_ref;
28462 }
28463
28464 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint64_t this_obj) {
28465         LDKPing this_obj_conv;
28466         this_obj_conv.inner = untag_ptr(this_obj);
28467         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28469         Ping_free(this_obj_conv);
28470 }
28471
28472 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint64_t this_ptr) {
28473         LDKPing this_ptr_conv;
28474         this_ptr_conv.inner = untag_ptr(this_ptr);
28475         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28477         this_ptr_conv.is_owned = false;
28478         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
28479         return ret_conv;
28480 }
28481
28482 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint64_t this_ptr, int16_t val) {
28483         LDKPing this_ptr_conv;
28484         this_ptr_conv.inner = untag_ptr(this_ptr);
28485         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28487         this_ptr_conv.is_owned = false;
28488         Ping_set_ponglen(&this_ptr_conv, val);
28489 }
28490
28491 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint64_t this_ptr) {
28492         LDKPing this_ptr_conv;
28493         this_ptr_conv.inner = untag_ptr(this_ptr);
28494         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28496         this_ptr_conv.is_owned = false;
28497         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
28498         return ret_conv;
28499 }
28500
28501 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint64_t this_ptr, int16_t val) {
28502         LDKPing this_ptr_conv;
28503         this_ptr_conv.inner = untag_ptr(this_ptr);
28504         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28506         this_ptr_conv.is_owned = false;
28507         Ping_set_byteslen(&this_ptr_conv, val);
28508 }
28509
28510 uint64_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
28511         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
28512         uint64_t ret_ref = 0;
28513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28514         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28515         return ret_ref;
28516 }
28517
28518 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
28519         LDKPing ret_var = Ping_clone(arg);
28520         uint64_t ret_ref = 0;
28521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28522         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28523         return ret_ref;
28524 }
28525 int64_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint64_t arg) {
28526         LDKPing arg_conv;
28527         arg_conv.inner = untag_ptr(arg);
28528         arg_conv.is_owned = ptr_is_owned(arg);
28529         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28530         arg_conv.is_owned = false;
28531         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
28532         return ret_conv;
28533 }
28534
28535 uint64_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint64_t orig) {
28536         LDKPing orig_conv;
28537         orig_conv.inner = untag_ptr(orig);
28538         orig_conv.is_owned = ptr_is_owned(orig);
28539         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28540         orig_conv.is_owned = false;
28541         LDKPing ret_var = Ping_clone(&orig_conv);
28542         uint64_t ret_ref = 0;
28543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28544         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28545         return ret_ref;
28546 }
28547
28548 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint64_t this_obj) {
28549         LDKPong this_obj_conv;
28550         this_obj_conv.inner = untag_ptr(this_obj);
28551         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28553         Pong_free(this_obj_conv);
28554 }
28555
28556 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint64_t this_ptr) {
28557         LDKPong this_ptr_conv;
28558         this_ptr_conv.inner = untag_ptr(this_ptr);
28559         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28561         this_ptr_conv.is_owned = false;
28562         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
28563         return ret_conv;
28564 }
28565
28566 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint64_t this_ptr, int16_t val) {
28567         LDKPong this_ptr_conv;
28568         this_ptr_conv.inner = untag_ptr(this_ptr);
28569         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28571         this_ptr_conv.is_owned = false;
28572         Pong_set_byteslen(&this_ptr_conv, val);
28573 }
28574
28575 uint64_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
28576         LDKPong ret_var = Pong_new(byteslen_arg);
28577         uint64_t ret_ref = 0;
28578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28579         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28580         return ret_ref;
28581 }
28582
28583 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
28584         LDKPong ret_var = Pong_clone(arg);
28585         uint64_t ret_ref = 0;
28586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28587         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28588         return ret_ref;
28589 }
28590 int64_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint64_t arg) {
28591         LDKPong arg_conv;
28592         arg_conv.inner = untag_ptr(arg);
28593         arg_conv.is_owned = ptr_is_owned(arg);
28594         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28595         arg_conv.is_owned = false;
28596         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
28597         return ret_conv;
28598 }
28599
28600 uint64_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint64_t orig) {
28601         LDKPong orig_conv;
28602         orig_conv.inner = untag_ptr(orig);
28603         orig_conv.is_owned = ptr_is_owned(orig);
28604         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28605         orig_conv.is_owned = false;
28606         LDKPong ret_var = Pong_clone(&orig_conv);
28607         uint64_t ret_ref = 0;
28608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28609         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28610         return ret_ref;
28611 }
28612
28613 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint64_t this_obj) {
28614         LDKOpenChannel this_obj_conv;
28615         this_obj_conv.inner = untag_ptr(this_obj);
28616         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28618         OpenChannel_free(this_obj_conv);
28619 }
28620
28621 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint64_t this_ptr) {
28622         LDKOpenChannel this_ptr_conv;
28623         this_ptr_conv.inner = untag_ptr(this_ptr);
28624         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28626         this_ptr_conv.is_owned = false;
28627         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28628         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
28629         return ret_arr;
28630 }
28631
28632 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint64_t this_ptr, int8_tArray val) {
28633         LDKOpenChannel this_ptr_conv;
28634         this_ptr_conv.inner = untag_ptr(this_ptr);
28635         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28637         this_ptr_conv.is_owned = false;
28638         LDKThirtyTwoBytes val_ref;
28639         CHECK(val->arr_len == 32);
28640         memcpy(val_ref.data, val->elems, 32); FREE(val);
28641         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
28642 }
28643
28644 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint64_t this_ptr) {
28645         LDKOpenChannel this_ptr_conv;
28646         this_ptr_conv.inner = untag_ptr(this_ptr);
28647         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28649         this_ptr_conv.is_owned = false;
28650         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28651         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
28652         return ret_arr;
28653 }
28654
28655 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint64_t this_ptr, int8_tArray val) {
28656         LDKOpenChannel this_ptr_conv;
28657         this_ptr_conv.inner = untag_ptr(this_ptr);
28658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28660         this_ptr_conv.is_owned = false;
28661         LDKThirtyTwoBytes val_ref;
28662         CHECK(val->arr_len == 32);
28663         memcpy(val_ref.data, val->elems, 32); FREE(val);
28664         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
28665 }
28666
28667 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint64_t this_ptr) {
28668         LDKOpenChannel this_ptr_conv;
28669         this_ptr_conv.inner = untag_ptr(this_ptr);
28670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28672         this_ptr_conv.is_owned = false;
28673         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
28674         return ret_conv;
28675 }
28676
28677 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint64_t this_ptr, int64_t val) {
28678         LDKOpenChannel this_ptr_conv;
28679         this_ptr_conv.inner = untag_ptr(this_ptr);
28680         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28682         this_ptr_conv.is_owned = false;
28683         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
28684 }
28685
28686 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint64_t this_ptr) {
28687         LDKOpenChannel this_ptr_conv;
28688         this_ptr_conv.inner = untag_ptr(this_ptr);
28689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28691         this_ptr_conv.is_owned = false;
28692         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
28693         return ret_conv;
28694 }
28695
28696 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint64_t this_ptr, int64_t val) {
28697         LDKOpenChannel this_ptr_conv;
28698         this_ptr_conv.inner = untag_ptr(this_ptr);
28699         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28701         this_ptr_conv.is_owned = false;
28702         OpenChannel_set_push_msat(&this_ptr_conv, val);
28703 }
28704
28705 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint64_t this_ptr) {
28706         LDKOpenChannel this_ptr_conv;
28707         this_ptr_conv.inner = untag_ptr(this_ptr);
28708         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28710         this_ptr_conv.is_owned = false;
28711         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
28712         return ret_conv;
28713 }
28714
28715 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint64_t this_ptr, int64_t val) {
28716         LDKOpenChannel this_ptr_conv;
28717         this_ptr_conv.inner = untag_ptr(this_ptr);
28718         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28720         this_ptr_conv.is_owned = false;
28721         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
28722 }
28723
28724 int64_t  __attribute__((export_name("TS_OpenChannel_get_max_htlc_value_in_flight_msat"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint64_t this_ptr) {
28725         LDKOpenChannel this_ptr_conv;
28726         this_ptr_conv.inner = untag_ptr(this_ptr);
28727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28729         this_ptr_conv.is_owned = false;
28730         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
28731         return ret_conv;
28732 }
28733
28734 void  __attribute__((export_name("TS_OpenChannel_set_max_htlc_value_in_flight_msat"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint64_t this_ptr, int64_t val) {
28735         LDKOpenChannel this_ptr_conv;
28736         this_ptr_conv.inner = untag_ptr(this_ptr);
28737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28739         this_ptr_conv.is_owned = false;
28740         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28741 }
28742
28743 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint64_t this_ptr) {
28744         LDKOpenChannel this_ptr_conv;
28745         this_ptr_conv.inner = untag_ptr(this_ptr);
28746         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28748         this_ptr_conv.is_owned = false;
28749         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
28750         return ret_conv;
28751 }
28752
28753 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint64_t this_ptr, int64_t val) {
28754         LDKOpenChannel this_ptr_conv;
28755         this_ptr_conv.inner = untag_ptr(this_ptr);
28756         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28758         this_ptr_conv.is_owned = false;
28759         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
28760 }
28761
28762 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint64_t this_ptr) {
28763         LDKOpenChannel this_ptr_conv;
28764         this_ptr_conv.inner = untag_ptr(this_ptr);
28765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28767         this_ptr_conv.is_owned = false;
28768         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
28769         return ret_conv;
28770 }
28771
28772 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint64_t this_ptr, int64_t val) {
28773         LDKOpenChannel this_ptr_conv;
28774         this_ptr_conv.inner = untag_ptr(this_ptr);
28775         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28777         this_ptr_conv.is_owned = false;
28778         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
28779 }
28780
28781 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint64_t this_ptr) {
28782         LDKOpenChannel this_ptr_conv;
28783         this_ptr_conv.inner = untag_ptr(this_ptr);
28784         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28786         this_ptr_conv.is_owned = false;
28787         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
28788         return ret_conv;
28789 }
28790
28791 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint64_t this_ptr, int32_t val) {
28792         LDKOpenChannel this_ptr_conv;
28793         this_ptr_conv.inner = untag_ptr(this_ptr);
28794         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28796         this_ptr_conv.is_owned = false;
28797         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
28798 }
28799
28800 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint64_t this_ptr) {
28801         LDKOpenChannel this_ptr_conv;
28802         this_ptr_conv.inner = untag_ptr(this_ptr);
28803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28805         this_ptr_conv.is_owned = false;
28806         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
28807         return ret_conv;
28808 }
28809
28810 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint64_t this_ptr, int16_t val) {
28811         LDKOpenChannel this_ptr_conv;
28812         this_ptr_conv.inner = untag_ptr(this_ptr);
28813         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28815         this_ptr_conv.is_owned = false;
28816         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
28817 }
28818
28819 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint64_t this_ptr) {
28820         LDKOpenChannel this_ptr_conv;
28821         this_ptr_conv.inner = untag_ptr(this_ptr);
28822         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28824         this_ptr_conv.is_owned = false;
28825         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
28826         return ret_conv;
28827 }
28828
28829 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint64_t this_ptr, int16_t val) {
28830         LDKOpenChannel this_ptr_conv;
28831         this_ptr_conv.inner = untag_ptr(this_ptr);
28832         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28834         this_ptr_conv.is_owned = false;
28835         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
28836 }
28837
28838 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint64_t this_ptr) {
28839         LDKOpenChannel this_ptr_conv;
28840         this_ptr_conv.inner = untag_ptr(this_ptr);
28841         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28843         this_ptr_conv.is_owned = false;
28844         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28845         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
28846         return ret_arr;
28847 }
28848
28849 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint64_t this_ptr, int8_tArray val) {
28850         LDKOpenChannel this_ptr_conv;
28851         this_ptr_conv.inner = untag_ptr(this_ptr);
28852         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28854         this_ptr_conv.is_owned = false;
28855         LDKPublicKey val_ref;
28856         CHECK(val->arr_len == 33);
28857         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28858         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
28859 }
28860
28861 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint64_t this_ptr) {
28862         LDKOpenChannel this_ptr_conv;
28863         this_ptr_conv.inner = untag_ptr(this_ptr);
28864         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28866         this_ptr_conv.is_owned = false;
28867         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28868         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
28869         return ret_arr;
28870 }
28871
28872 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint64_t this_ptr, int8_tArray val) {
28873         LDKOpenChannel this_ptr_conv;
28874         this_ptr_conv.inner = untag_ptr(this_ptr);
28875         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28877         this_ptr_conv.is_owned = false;
28878         LDKPublicKey val_ref;
28879         CHECK(val->arr_len == 33);
28880         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28881         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
28882 }
28883
28884 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint64_t this_ptr) {
28885         LDKOpenChannel this_ptr_conv;
28886         this_ptr_conv.inner = untag_ptr(this_ptr);
28887         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28889         this_ptr_conv.is_owned = false;
28890         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28891         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
28892         return ret_arr;
28893 }
28894
28895 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint64_t this_ptr, int8_tArray val) {
28896         LDKOpenChannel this_ptr_conv;
28897         this_ptr_conv.inner = untag_ptr(this_ptr);
28898         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28900         this_ptr_conv.is_owned = false;
28901         LDKPublicKey val_ref;
28902         CHECK(val->arr_len == 33);
28903         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28904         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
28905 }
28906
28907 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint64_t this_ptr) {
28908         LDKOpenChannel this_ptr_conv;
28909         this_ptr_conv.inner = untag_ptr(this_ptr);
28910         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28912         this_ptr_conv.is_owned = false;
28913         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28914         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
28915         return ret_arr;
28916 }
28917
28918 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint64_t this_ptr, int8_tArray val) {
28919         LDKOpenChannel this_ptr_conv;
28920         this_ptr_conv.inner = untag_ptr(this_ptr);
28921         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28923         this_ptr_conv.is_owned = false;
28924         LDKPublicKey val_ref;
28925         CHECK(val->arr_len == 33);
28926         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28927         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
28928 }
28929
28930 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint64_t this_ptr) {
28931         LDKOpenChannel this_ptr_conv;
28932         this_ptr_conv.inner = untag_ptr(this_ptr);
28933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28935         this_ptr_conv.is_owned = false;
28936         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28937         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
28938         return ret_arr;
28939 }
28940
28941 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint64_t this_ptr, int8_tArray val) {
28942         LDKOpenChannel this_ptr_conv;
28943         this_ptr_conv.inner = untag_ptr(this_ptr);
28944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28946         this_ptr_conv.is_owned = false;
28947         LDKPublicKey val_ref;
28948         CHECK(val->arr_len == 33);
28949         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28950         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
28951 }
28952
28953 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint64_t this_ptr) {
28954         LDKOpenChannel this_ptr_conv;
28955         this_ptr_conv.inner = untag_ptr(this_ptr);
28956         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28958         this_ptr_conv.is_owned = false;
28959         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28960         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28961         return ret_arr;
28962 }
28963
28964 void  __attribute__((export_name("TS_OpenChannel_set_first_per_commitment_point"))) TS_OpenChannel_set_first_per_commitment_point(uint64_t this_ptr, int8_tArray val) {
28965         LDKOpenChannel this_ptr_conv;
28966         this_ptr_conv.inner = untag_ptr(this_ptr);
28967         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28969         this_ptr_conv.is_owned = false;
28970         LDKPublicKey val_ref;
28971         CHECK(val->arr_len == 33);
28972         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28973         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
28974 }
28975
28976 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint64_t this_ptr) {
28977         LDKOpenChannel this_ptr_conv;
28978         this_ptr_conv.inner = untag_ptr(this_ptr);
28979         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28981         this_ptr_conv.is_owned = false;
28982         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
28983         return ret_conv;
28984 }
28985
28986 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint64_t this_ptr, int8_t val) {
28987         LDKOpenChannel this_ptr_conv;
28988         this_ptr_conv.inner = untag_ptr(this_ptr);
28989         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28991         this_ptr_conv.is_owned = false;
28992         OpenChannel_set_channel_flags(&this_ptr_conv, val);
28993 }
28994
28995 uint64_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint64_t this_ptr) {
28996         LDKOpenChannel this_ptr_conv;
28997         this_ptr_conv.inner = untag_ptr(this_ptr);
28998         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29000         this_ptr_conv.is_owned = false;
29001         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
29002         uint64_t ret_ref = 0;
29003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29004         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29005         return ret_ref;
29006 }
29007
29008 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint64_t this_ptr, uint64_t val) {
29009         LDKOpenChannel this_ptr_conv;
29010         this_ptr_conv.inner = untag_ptr(this_ptr);
29011         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29013         this_ptr_conv.is_owned = false;
29014         LDKChannelTypeFeatures val_conv;
29015         val_conv.inner = untag_ptr(val);
29016         val_conv.is_owned = ptr_is_owned(val);
29017         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29018         val_conv = ChannelTypeFeatures_clone(&val_conv);
29019         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
29020 }
29021
29022 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
29023         LDKOpenChannel ret_var = OpenChannel_clone(arg);
29024         uint64_t ret_ref = 0;
29025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29026         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29027         return ret_ref;
29028 }
29029 int64_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint64_t arg) {
29030         LDKOpenChannel arg_conv;
29031         arg_conv.inner = untag_ptr(arg);
29032         arg_conv.is_owned = ptr_is_owned(arg);
29033         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29034         arg_conv.is_owned = false;
29035         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
29036         return ret_conv;
29037 }
29038
29039 uint64_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint64_t orig) {
29040         LDKOpenChannel orig_conv;
29041         orig_conv.inner = untag_ptr(orig);
29042         orig_conv.is_owned = ptr_is_owned(orig);
29043         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29044         orig_conv.is_owned = false;
29045         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
29046         uint64_t ret_ref = 0;
29047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29048         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29049         return ret_ref;
29050 }
29051
29052 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint64_t this_obj) {
29053         LDKAcceptChannel this_obj_conv;
29054         this_obj_conv.inner = untag_ptr(this_obj);
29055         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29057         AcceptChannel_free(this_obj_conv);
29058 }
29059
29060 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint64_t this_ptr) {
29061         LDKAcceptChannel this_ptr_conv;
29062         this_ptr_conv.inner = untag_ptr(this_ptr);
29063         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29065         this_ptr_conv.is_owned = false;
29066         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29067         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
29068         return ret_arr;
29069 }
29070
29071 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint64_t this_ptr, int8_tArray val) {
29072         LDKAcceptChannel this_ptr_conv;
29073         this_ptr_conv.inner = untag_ptr(this_ptr);
29074         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29076         this_ptr_conv.is_owned = false;
29077         LDKThirtyTwoBytes val_ref;
29078         CHECK(val->arr_len == 32);
29079         memcpy(val_ref.data, val->elems, 32); FREE(val);
29080         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
29081 }
29082
29083 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint64_t this_ptr) {
29084         LDKAcceptChannel this_ptr_conv;
29085         this_ptr_conv.inner = untag_ptr(this_ptr);
29086         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29088         this_ptr_conv.is_owned = false;
29089         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
29090         return ret_conv;
29091 }
29092
29093 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint64_t this_ptr, int64_t val) {
29094         LDKAcceptChannel this_ptr_conv;
29095         this_ptr_conv.inner = untag_ptr(this_ptr);
29096         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29098         this_ptr_conv.is_owned = false;
29099         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
29100 }
29101
29102 int64_t  __attribute__((export_name("TS_AcceptChannel_get_max_htlc_value_in_flight_msat"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint64_t this_ptr) {
29103         LDKAcceptChannel this_ptr_conv;
29104         this_ptr_conv.inner = untag_ptr(this_ptr);
29105         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29107         this_ptr_conv.is_owned = false;
29108         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
29109         return ret_conv;
29110 }
29111
29112 void  __attribute__((export_name("TS_AcceptChannel_set_max_htlc_value_in_flight_msat"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint64_t this_ptr, int64_t val) {
29113         LDKAcceptChannel this_ptr_conv;
29114         this_ptr_conv.inner = untag_ptr(this_ptr);
29115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29117         this_ptr_conv.is_owned = false;
29118         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
29119 }
29120
29121 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint64_t this_ptr) {
29122         LDKAcceptChannel this_ptr_conv;
29123         this_ptr_conv.inner = untag_ptr(this_ptr);
29124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29126         this_ptr_conv.is_owned = false;
29127         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
29128         return ret_conv;
29129 }
29130
29131 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint64_t this_ptr, int64_t val) {
29132         LDKAcceptChannel this_ptr_conv;
29133         this_ptr_conv.inner = untag_ptr(this_ptr);
29134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29136         this_ptr_conv.is_owned = false;
29137         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
29138 }
29139
29140 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint64_t this_ptr) {
29141         LDKAcceptChannel this_ptr_conv;
29142         this_ptr_conv.inner = untag_ptr(this_ptr);
29143         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29145         this_ptr_conv.is_owned = false;
29146         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
29147         return ret_conv;
29148 }
29149
29150 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint64_t this_ptr, int64_t val) {
29151         LDKAcceptChannel this_ptr_conv;
29152         this_ptr_conv.inner = untag_ptr(this_ptr);
29153         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29155         this_ptr_conv.is_owned = false;
29156         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
29157 }
29158
29159 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint64_t this_ptr) {
29160         LDKAcceptChannel this_ptr_conv;
29161         this_ptr_conv.inner = untag_ptr(this_ptr);
29162         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29164         this_ptr_conv.is_owned = false;
29165         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
29166         return ret_conv;
29167 }
29168
29169 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint64_t this_ptr, int32_t val) {
29170         LDKAcceptChannel this_ptr_conv;
29171         this_ptr_conv.inner = untag_ptr(this_ptr);
29172         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29174         this_ptr_conv.is_owned = false;
29175         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
29176 }
29177
29178 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint64_t this_ptr) {
29179         LDKAcceptChannel this_ptr_conv;
29180         this_ptr_conv.inner = untag_ptr(this_ptr);
29181         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29183         this_ptr_conv.is_owned = false;
29184         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
29185         return ret_conv;
29186 }
29187
29188 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint64_t this_ptr, int16_t val) {
29189         LDKAcceptChannel this_ptr_conv;
29190         this_ptr_conv.inner = untag_ptr(this_ptr);
29191         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29193         this_ptr_conv.is_owned = false;
29194         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
29195 }
29196
29197 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint64_t this_ptr) {
29198         LDKAcceptChannel this_ptr_conv;
29199         this_ptr_conv.inner = untag_ptr(this_ptr);
29200         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29202         this_ptr_conv.is_owned = false;
29203         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
29204         return ret_conv;
29205 }
29206
29207 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint64_t this_ptr, int16_t val) {
29208         LDKAcceptChannel this_ptr_conv;
29209         this_ptr_conv.inner = untag_ptr(this_ptr);
29210         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29212         this_ptr_conv.is_owned = false;
29213         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
29214 }
29215
29216 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint64_t this_ptr) {
29217         LDKAcceptChannel this_ptr_conv;
29218         this_ptr_conv.inner = untag_ptr(this_ptr);
29219         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29221         this_ptr_conv.is_owned = false;
29222         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29223         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
29224         return ret_arr;
29225 }
29226
29227 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint64_t this_ptr, int8_tArray val) {
29228         LDKAcceptChannel this_ptr_conv;
29229         this_ptr_conv.inner = untag_ptr(this_ptr);
29230         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29232         this_ptr_conv.is_owned = false;
29233         LDKPublicKey val_ref;
29234         CHECK(val->arr_len == 33);
29235         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29236         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
29237 }
29238
29239 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint64_t this_ptr) {
29240         LDKAcceptChannel this_ptr_conv;
29241         this_ptr_conv.inner = untag_ptr(this_ptr);
29242         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29244         this_ptr_conv.is_owned = false;
29245         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29246         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
29247         return ret_arr;
29248 }
29249
29250 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint64_t this_ptr, int8_tArray val) {
29251         LDKAcceptChannel this_ptr_conv;
29252         this_ptr_conv.inner = untag_ptr(this_ptr);
29253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29255         this_ptr_conv.is_owned = false;
29256         LDKPublicKey val_ref;
29257         CHECK(val->arr_len == 33);
29258         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29259         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
29260 }
29261
29262 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint64_t this_ptr) {
29263         LDKAcceptChannel this_ptr_conv;
29264         this_ptr_conv.inner = untag_ptr(this_ptr);
29265         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29267         this_ptr_conv.is_owned = false;
29268         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29269         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
29270         return ret_arr;
29271 }
29272
29273 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint64_t this_ptr, int8_tArray val) {
29274         LDKAcceptChannel this_ptr_conv;
29275         this_ptr_conv.inner = untag_ptr(this_ptr);
29276         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29278         this_ptr_conv.is_owned = false;
29279         LDKPublicKey val_ref;
29280         CHECK(val->arr_len == 33);
29281         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29282         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
29283 }
29284
29285 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint64_t this_ptr) {
29286         LDKAcceptChannel this_ptr_conv;
29287         this_ptr_conv.inner = untag_ptr(this_ptr);
29288         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29290         this_ptr_conv.is_owned = false;
29291         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29292         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
29293         return ret_arr;
29294 }
29295
29296 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint64_t this_ptr, int8_tArray val) {
29297         LDKAcceptChannel this_ptr_conv;
29298         this_ptr_conv.inner = untag_ptr(this_ptr);
29299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29301         this_ptr_conv.is_owned = false;
29302         LDKPublicKey val_ref;
29303         CHECK(val->arr_len == 33);
29304         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29305         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
29306 }
29307
29308 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint64_t this_ptr) {
29309         LDKAcceptChannel this_ptr_conv;
29310         this_ptr_conv.inner = untag_ptr(this_ptr);
29311         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29313         this_ptr_conv.is_owned = false;
29314         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29315         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
29316         return ret_arr;
29317 }
29318
29319 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint64_t this_ptr, int8_tArray val) {
29320         LDKAcceptChannel this_ptr_conv;
29321         this_ptr_conv.inner = untag_ptr(this_ptr);
29322         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29324         this_ptr_conv.is_owned = false;
29325         LDKPublicKey val_ref;
29326         CHECK(val->arr_len == 33);
29327         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29328         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
29329 }
29330
29331 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint64_t this_ptr) {
29332         LDKAcceptChannel this_ptr_conv;
29333         this_ptr_conv.inner = untag_ptr(this_ptr);
29334         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29336         this_ptr_conv.is_owned = false;
29337         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29338         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29339         return ret_arr;
29340 }
29341
29342 void  __attribute__((export_name("TS_AcceptChannel_set_first_per_commitment_point"))) TS_AcceptChannel_set_first_per_commitment_point(uint64_t this_ptr, int8_tArray val) {
29343         LDKAcceptChannel this_ptr_conv;
29344         this_ptr_conv.inner = untag_ptr(this_ptr);
29345         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29347         this_ptr_conv.is_owned = false;
29348         LDKPublicKey val_ref;
29349         CHECK(val->arr_len == 33);
29350         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29351         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
29352 }
29353
29354 uint64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_type"))) TS_AcceptChannel_get_channel_type(uint64_t this_ptr) {
29355         LDKAcceptChannel this_ptr_conv;
29356         this_ptr_conv.inner = untag_ptr(this_ptr);
29357         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29359         this_ptr_conv.is_owned = false;
29360         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
29361         uint64_t ret_ref = 0;
29362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29363         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29364         return ret_ref;
29365 }
29366
29367 void  __attribute__((export_name("TS_AcceptChannel_set_channel_type"))) TS_AcceptChannel_set_channel_type(uint64_t this_ptr, uint64_t val) {
29368         LDKAcceptChannel this_ptr_conv;
29369         this_ptr_conv.inner = untag_ptr(this_ptr);
29370         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29372         this_ptr_conv.is_owned = false;
29373         LDKChannelTypeFeatures val_conv;
29374         val_conv.inner = untag_ptr(val);
29375         val_conv.is_owned = ptr_is_owned(val);
29376         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29377         val_conv = ChannelTypeFeatures_clone(&val_conv);
29378         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
29379 }
29380
29381 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
29382         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
29383         uint64_t ret_ref = 0;
29384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29385         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29386         return ret_ref;
29387 }
29388 int64_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint64_t arg) {
29389         LDKAcceptChannel arg_conv;
29390         arg_conv.inner = untag_ptr(arg);
29391         arg_conv.is_owned = ptr_is_owned(arg);
29392         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29393         arg_conv.is_owned = false;
29394         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
29395         return ret_conv;
29396 }
29397
29398 uint64_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint64_t orig) {
29399         LDKAcceptChannel orig_conv;
29400         orig_conv.inner = untag_ptr(orig);
29401         orig_conv.is_owned = ptr_is_owned(orig);
29402         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29403         orig_conv.is_owned = false;
29404         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
29405         uint64_t ret_ref = 0;
29406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29407         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29408         return ret_ref;
29409 }
29410
29411 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint64_t this_obj) {
29412         LDKFundingCreated this_obj_conv;
29413         this_obj_conv.inner = untag_ptr(this_obj);
29414         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29416         FundingCreated_free(this_obj_conv);
29417 }
29418
29419 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint64_t this_ptr) {
29420         LDKFundingCreated this_ptr_conv;
29421         this_ptr_conv.inner = untag_ptr(this_ptr);
29422         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29424         this_ptr_conv.is_owned = false;
29425         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29426         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
29427         return ret_arr;
29428 }
29429
29430 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint64_t this_ptr, int8_tArray val) {
29431         LDKFundingCreated this_ptr_conv;
29432         this_ptr_conv.inner = untag_ptr(this_ptr);
29433         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29435         this_ptr_conv.is_owned = false;
29436         LDKThirtyTwoBytes val_ref;
29437         CHECK(val->arr_len == 32);
29438         memcpy(val_ref.data, val->elems, 32); FREE(val);
29439         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
29440 }
29441
29442 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint64_t this_ptr) {
29443         LDKFundingCreated this_ptr_conv;
29444         this_ptr_conv.inner = untag_ptr(this_ptr);
29445         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29447         this_ptr_conv.is_owned = false;
29448         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29449         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
29450         return ret_arr;
29451 }
29452
29453 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint64_t this_ptr, int8_tArray val) {
29454         LDKFundingCreated this_ptr_conv;
29455         this_ptr_conv.inner = untag_ptr(this_ptr);
29456         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29458         this_ptr_conv.is_owned = false;
29459         LDKThirtyTwoBytes val_ref;
29460         CHECK(val->arr_len == 32);
29461         memcpy(val_ref.data, val->elems, 32); FREE(val);
29462         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
29463 }
29464
29465 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint64_t this_ptr) {
29466         LDKFundingCreated this_ptr_conv;
29467         this_ptr_conv.inner = untag_ptr(this_ptr);
29468         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29470         this_ptr_conv.is_owned = false;
29471         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
29472         return ret_conv;
29473 }
29474
29475 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint64_t this_ptr, int16_t val) {
29476         LDKFundingCreated this_ptr_conv;
29477         this_ptr_conv.inner = untag_ptr(this_ptr);
29478         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29480         this_ptr_conv.is_owned = false;
29481         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
29482 }
29483
29484 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint64_t this_ptr) {
29485         LDKFundingCreated this_ptr_conv;
29486         this_ptr_conv.inner = untag_ptr(this_ptr);
29487         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29489         this_ptr_conv.is_owned = false;
29490         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29491         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
29492         return ret_arr;
29493 }
29494
29495 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint64_t this_ptr, int8_tArray val) {
29496         LDKFundingCreated this_ptr_conv;
29497         this_ptr_conv.inner = untag_ptr(this_ptr);
29498         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29500         this_ptr_conv.is_owned = false;
29501         LDKSignature val_ref;
29502         CHECK(val->arr_len == 64);
29503         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29504         FundingCreated_set_signature(&this_ptr_conv, val_ref);
29505 }
29506
29507 uint64_t  __attribute__((export_name("TS_FundingCreated_new"))) TS_FundingCreated_new(int8_tArray temporary_channel_id_arg, int8_tArray funding_txid_arg, int16_t funding_output_index_arg, int8_tArray signature_arg) {
29508         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
29509         CHECK(temporary_channel_id_arg->arr_len == 32);
29510         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
29511         LDKThirtyTwoBytes funding_txid_arg_ref;
29512         CHECK(funding_txid_arg->arr_len == 32);
29513         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
29514         LDKSignature signature_arg_ref;
29515         CHECK(signature_arg->arr_len == 64);
29516         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29517         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
29518         uint64_t ret_ref = 0;
29519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29520         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29521         return ret_ref;
29522 }
29523
29524 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
29525         LDKFundingCreated ret_var = FundingCreated_clone(arg);
29526         uint64_t ret_ref = 0;
29527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29528         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29529         return ret_ref;
29530 }
29531 int64_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint64_t arg) {
29532         LDKFundingCreated arg_conv;
29533         arg_conv.inner = untag_ptr(arg);
29534         arg_conv.is_owned = ptr_is_owned(arg);
29535         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29536         arg_conv.is_owned = false;
29537         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
29538         return ret_conv;
29539 }
29540
29541 uint64_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint64_t orig) {
29542         LDKFundingCreated orig_conv;
29543         orig_conv.inner = untag_ptr(orig);
29544         orig_conv.is_owned = ptr_is_owned(orig);
29545         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29546         orig_conv.is_owned = false;
29547         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
29548         uint64_t ret_ref = 0;
29549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29550         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29551         return ret_ref;
29552 }
29553
29554 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint64_t this_obj) {
29555         LDKFundingSigned this_obj_conv;
29556         this_obj_conv.inner = untag_ptr(this_obj);
29557         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29559         FundingSigned_free(this_obj_conv);
29560 }
29561
29562 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint64_t this_ptr) {
29563         LDKFundingSigned this_ptr_conv;
29564         this_ptr_conv.inner = untag_ptr(this_ptr);
29565         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29567         this_ptr_conv.is_owned = false;
29568         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29569         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
29570         return ret_arr;
29571 }
29572
29573 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint64_t this_ptr, int8_tArray val) {
29574         LDKFundingSigned this_ptr_conv;
29575         this_ptr_conv.inner = untag_ptr(this_ptr);
29576         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29578         this_ptr_conv.is_owned = false;
29579         LDKThirtyTwoBytes val_ref;
29580         CHECK(val->arr_len == 32);
29581         memcpy(val_ref.data, val->elems, 32); FREE(val);
29582         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
29583 }
29584
29585 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint64_t this_ptr) {
29586         LDKFundingSigned this_ptr_conv;
29587         this_ptr_conv.inner = untag_ptr(this_ptr);
29588         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29590         this_ptr_conv.is_owned = false;
29591         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29592         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
29593         return ret_arr;
29594 }
29595
29596 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint64_t this_ptr, int8_tArray val) {
29597         LDKFundingSigned this_ptr_conv;
29598         this_ptr_conv.inner = untag_ptr(this_ptr);
29599         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29601         this_ptr_conv.is_owned = false;
29602         LDKSignature val_ref;
29603         CHECK(val->arr_len == 64);
29604         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29605         FundingSigned_set_signature(&this_ptr_conv, val_ref);
29606 }
29607
29608 uint64_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
29609         LDKThirtyTwoBytes channel_id_arg_ref;
29610         CHECK(channel_id_arg->arr_len == 32);
29611         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29612         LDKSignature signature_arg_ref;
29613         CHECK(signature_arg->arr_len == 64);
29614         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29615         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
29616         uint64_t ret_ref = 0;
29617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29618         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29619         return ret_ref;
29620 }
29621
29622 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
29623         LDKFundingSigned ret_var = FundingSigned_clone(arg);
29624         uint64_t ret_ref = 0;
29625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29626         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29627         return ret_ref;
29628 }
29629 int64_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint64_t arg) {
29630         LDKFundingSigned arg_conv;
29631         arg_conv.inner = untag_ptr(arg);
29632         arg_conv.is_owned = ptr_is_owned(arg);
29633         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29634         arg_conv.is_owned = false;
29635         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
29636         return ret_conv;
29637 }
29638
29639 uint64_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint64_t orig) {
29640         LDKFundingSigned orig_conv;
29641         orig_conv.inner = untag_ptr(orig);
29642         orig_conv.is_owned = ptr_is_owned(orig);
29643         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29644         orig_conv.is_owned = false;
29645         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
29646         uint64_t ret_ref = 0;
29647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29648         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29649         return ret_ref;
29650 }
29651
29652 void  __attribute__((export_name("TS_ChannelReady_free"))) TS_ChannelReady_free(uint64_t this_obj) {
29653         LDKChannelReady this_obj_conv;
29654         this_obj_conv.inner = untag_ptr(this_obj);
29655         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29657         ChannelReady_free(this_obj_conv);
29658 }
29659
29660 int8_tArray  __attribute__((export_name("TS_ChannelReady_get_channel_id"))) TS_ChannelReady_get_channel_id(uint64_t this_ptr) {
29661         LDKChannelReady this_ptr_conv;
29662         this_ptr_conv.inner = untag_ptr(this_ptr);
29663         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29665         this_ptr_conv.is_owned = false;
29666         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29667         memcpy(ret_arr->elems, *ChannelReady_get_channel_id(&this_ptr_conv), 32);
29668         return ret_arr;
29669 }
29670
29671 void  __attribute__((export_name("TS_ChannelReady_set_channel_id"))) TS_ChannelReady_set_channel_id(uint64_t this_ptr, int8_tArray val) {
29672         LDKChannelReady this_ptr_conv;
29673         this_ptr_conv.inner = untag_ptr(this_ptr);
29674         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29676         this_ptr_conv.is_owned = false;
29677         LDKThirtyTwoBytes val_ref;
29678         CHECK(val->arr_len == 32);
29679         memcpy(val_ref.data, val->elems, 32); FREE(val);
29680         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
29681 }
29682
29683 int8_tArray  __attribute__((export_name("TS_ChannelReady_get_next_per_commitment_point"))) TS_ChannelReady_get_next_per_commitment_point(uint64_t this_ptr) {
29684         LDKChannelReady this_ptr_conv;
29685         this_ptr_conv.inner = untag_ptr(this_ptr);
29686         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29688         this_ptr_conv.is_owned = false;
29689         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29690         memcpy(ret_arr->elems, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29691         return ret_arr;
29692 }
29693
29694 void  __attribute__((export_name("TS_ChannelReady_set_next_per_commitment_point"))) TS_ChannelReady_set_next_per_commitment_point(uint64_t this_ptr, int8_tArray val) {
29695         LDKChannelReady this_ptr_conv;
29696         this_ptr_conv.inner = untag_ptr(this_ptr);
29697         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29699         this_ptr_conv.is_owned = false;
29700         LDKPublicKey val_ref;
29701         CHECK(val->arr_len == 33);
29702         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29703         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
29704 }
29705
29706 uint64_t  __attribute__((export_name("TS_ChannelReady_get_short_channel_id_alias"))) TS_ChannelReady_get_short_channel_id_alias(uint64_t this_ptr) {
29707         LDKChannelReady this_ptr_conv;
29708         this_ptr_conv.inner = untag_ptr(this_ptr);
29709         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29711         this_ptr_conv.is_owned = false;
29712         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29713         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
29714         uint64_t ret_ref = tag_ptr(ret_copy, true);
29715         return ret_ref;
29716 }
29717
29718 void  __attribute__((export_name("TS_ChannelReady_set_short_channel_id_alias"))) TS_ChannelReady_set_short_channel_id_alias(uint64_t this_ptr, uint64_t val) {
29719         LDKChannelReady this_ptr_conv;
29720         this_ptr_conv.inner = untag_ptr(this_ptr);
29721         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29723         this_ptr_conv.is_owned = false;
29724         void* val_ptr = untag_ptr(val);
29725         CHECK_ACCESS(val_ptr);
29726         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29727         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
29728         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
29729 }
29730
29731 uint64_t  __attribute__((export_name("TS_ChannelReady_new"))) TS_ChannelReady_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, uint64_t short_channel_id_alias_arg) {
29732         LDKThirtyTwoBytes channel_id_arg_ref;
29733         CHECK(channel_id_arg->arr_len == 32);
29734         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29735         LDKPublicKey next_per_commitment_point_arg_ref;
29736         CHECK(next_per_commitment_point_arg->arr_len == 33);
29737         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
29738         void* short_channel_id_alias_arg_ptr = untag_ptr(short_channel_id_alias_arg);
29739         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
29740         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
29741         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_alias_arg));
29742         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
29743         uint64_t ret_ref = 0;
29744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29745         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29746         return ret_ref;
29747 }
29748
29749 static inline uint64_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
29750         LDKChannelReady ret_var = ChannelReady_clone(arg);
29751         uint64_t ret_ref = 0;
29752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29753         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29754         return ret_ref;
29755 }
29756 int64_t  __attribute__((export_name("TS_ChannelReady_clone_ptr"))) TS_ChannelReady_clone_ptr(uint64_t arg) {
29757         LDKChannelReady arg_conv;
29758         arg_conv.inner = untag_ptr(arg);
29759         arg_conv.is_owned = ptr_is_owned(arg);
29760         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29761         arg_conv.is_owned = false;
29762         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
29763         return ret_conv;
29764 }
29765
29766 uint64_t  __attribute__((export_name("TS_ChannelReady_clone"))) TS_ChannelReady_clone(uint64_t orig) {
29767         LDKChannelReady orig_conv;
29768         orig_conv.inner = untag_ptr(orig);
29769         orig_conv.is_owned = ptr_is_owned(orig);
29770         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29771         orig_conv.is_owned = false;
29772         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
29773         uint64_t ret_ref = 0;
29774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29775         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29776         return ret_ref;
29777 }
29778
29779 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint64_t this_obj) {
29780         LDKShutdown this_obj_conv;
29781         this_obj_conv.inner = untag_ptr(this_obj);
29782         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29784         Shutdown_free(this_obj_conv);
29785 }
29786
29787 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint64_t this_ptr) {
29788         LDKShutdown this_ptr_conv;
29789         this_ptr_conv.inner = untag_ptr(this_ptr);
29790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29792         this_ptr_conv.is_owned = false;
29793         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29794         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
29795         return ret_arr;
29796 }
29797
29798 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint64_t this_ptr, int8_tArray val) {
29799         LDKShutdown this_ptr_conv;
29800         this_ptr_conv.inner = untag_ptr(this_ptr);
29801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29803         this_ptr_conv.is_owned = false;
29804         LDKThirtyTwoBytes val_ref;
29805         CHECK(val->arr_len == 32);
29806         memcpy(val_ref.data, val->elems, 32); FREE(val);
29807         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
29808 }
29809
29810 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint64_t this_ptr) {
29811         LDKShutdown this_ptr_conv;
29812         this_ptr_conv.inner = untag_ptr(this_ptr);
29813         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29815         this_ptr_conv.is_owned = false;
29816         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
29817         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29818         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29819         return ret_arr;
29820 }
29821
29822 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint64_t this_ptr, int8_tArray val) {
29823         LDKShutdown this_ptr_conv;
29824         this_ptr_conv.inner = untag_ptr(this_ptr);
29825         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29827         this_ptr_conv.is_owned = false;
29828         LDKCVec_u8Z val_ref;
29829         val_ref.datalen = val->arr_len;
29830         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
29831         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
29832         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
29833 }
29834
29835 uint64_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
29836         LDKThirtyTwoBytes channel_id_arg_ref;
29837         CHECK(channel_id_arg->arr_len == 32);
29838         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29839         LDKCVec_u8Z scriptpubkey_arg_ref;
29840         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
29841         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
29842         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
29843         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
29844         uint64_t ret_ref = 0;
29845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29846         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29847         return ret_ref;
29848 }
29849
29850 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
29851         LDKShutdown ret_var = Shutdown_clone(arg);
29852         uint64_t ret_ref = 0;
29853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29854         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29855         return ret_ref;
29856 }
29857 int64_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint64_t arg) {
29858         LDKShutdown arg_conv;
29859         arg_conv.inner = untag_ptr(arg);
29860         arg_conv.is_owned = ptr_is_owned(arg);
29861         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29862         arg_conv.is_owned = false;
29863         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
29864         return ret_conv;
29865 }
29866
29867 uint64_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint64_t orig) {
29868         LDKShutdown orig_conv;
29869         orig_conv.inner = untag_ptr(orig);
29870         orig_conv.is_owned = ptr_is_owned(orig);
29871         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29872         orig_conv.is_owned = false;
29873         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
29874         uint64_t ret_ref = 0;
29875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29876         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29877         return ret_ref;
29878 }
29879
29880 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint64_t this_obj) {
29881         LDKClosingSignedFeeRange this_obj_conv;
29882         this_obj_conv.inner = untag_ptr(this_obj);
29883         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29885         ClosingSignedFeeRange_free(this_obj_conv);
29886 }
29887
29888 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint64_t this_ptr) {
29889         LDKClosingSignedFeeRange this_ptr_conv;
29890         this_ptr_conv.inner = untag_ptr(this_ptr);
29891         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29893         this_ptr_conv.is_owned = false;
29894         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
29895         return ret_conv;
29896 }
29897
29898 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint64_t this_ptr, int64_t val) {
29899         LDKClosingSignedFeeRange this_ptr_conv;
29900         this_ptr_conv.inner = untag_ptr(this_ptr);
29901         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29903         this_ptr_conv.is_owned = false;
29904         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
29905 }
29906
29907 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint64_t this_ptr) {
29908         LDKClosingSignedFeeRange this_ptr_conv;
29909         this_ptr_conv.inner = untag_ptr(this_ptr);
29910         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29912         this_ptr_conv.is_owned = false;
29913         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
29914         return ret_conv;
29915 }
29916
29917 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint64_t this_ptr, int64_t val) {
29918         LDKClosingSignedFeeRange this_ptr_conv;
29919         this_ptr_conv.inner = untag_ptr(this_ptr);
29920         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29922         this_ptr_conv.is_owned = false;
29923         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
29924 }
29925
29926 uint64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
29927         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
29928         uint64_t ret_ref = 0;
29929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29930         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29931         return ret_ref;
29932 }
29933
29934 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
29935         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
29936         uint64_t ret_ref = 0;
29937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29938         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29939         return ret_ref;
29940 }
29941 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint64_t arg) {
29942         LDKClosingSignedFeeRange arg_conv;
29943         arg_conv.inner = untag_ptr(arg);
29944         arg_conv.is_owned = ptr_is_owned(arg);
29945         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29946         arg_conv.is_owned = false;
29947         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
29948         return ret_conv;
29949 }
29950
29951 uint64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint64_t orig) {
29952         LDKClosingSignedFeeRange orig_conv;
29953         orig_conv.inner = untag_ptr(orig);
29954         orig_conv.is_owned = ptr_is_owned(orig);
29955         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29956         orig_conv.is_owned = false;
29957         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
29958         uint64_t ret_ref = 0;
29959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29960         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29961         return ret_ref;
29962 }
29963
29964 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint64_t this_obj) {
29965         LDKClosingSigned this_obj_conv;
29966         this_obj_conv.inner = untag_ptr(this_obj);
29967         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29969         ClosingSigned_free(this_obj_conv);
29970 }
29971
29972 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint64_t this_ptr) {
29973         LDKClosingSigned this_ptr_conv;
29974         this_ptr_conv.inner = untag_ptr(this_ptr);
29975         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29977         this_ptr_conv.is_owned = false;
29978         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29979         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
29980         return ret_arr;
29981 }
29982
29983 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint64_t this_ptr, int8_tArray val) {
29984         LDKClosingSigned this_ptr_conv;
29985         this_ptr_conv.inner = untag_ptr(this_ptr);
29986         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29988         this_ptr_conv.is_owned = false;
29989         LDKThirtyTwoBytes val_ref;
29990         CHECK(val->arr_len == 32);
29991         memcpy(val_ref.data, val->elems, 32); FREE(val);
29992         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
29993 }
29994
29995 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint64_t this_ptr) {
29996         LDKClosingSigned this_ptr_conv;
29997         this_ptr_conv.inner = untag_ptr(this_ptr);
29998         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30000         this_ptr_conv.is_owned = false;
30001         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
30002         return ret_conv;
30003 }
30004
30005 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint64_t this_ptr, int64_t val) {
30006         LDKClosingSigned this_ptr_conv;
30007         this_ptr_conv.inner = untag_ptr(this_ptr);
30008         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30010         this_ptr_conv.is_owned = false;
30011         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
30012 }
30013
30014 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint64_t this_ptr) {
30015         LDKClosingSigned this_ptr_conv;
30016         this_ptr_conv.inner = untag_ptr(this_ptr);
30017         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30019         this_ptr_conv.is_owned = false;
30020         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30021         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
30022         return ret_arr;
30023 }
30024
30025 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint64_t this_ptr, int8_tArray val) {
30026         LDKClosingSigned this_ptr_conv;
30027         this_ptr_conv.inner = untag_ptr(this_ptr);
30028         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30030         this_ptr_conv.is_owned = false;
30031         LDKSignature val_ref;
30032         CHECK(val->arr_len == 64);
30033         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30034         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
30035 }
30036
30037 uint64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint64_t this_ptr) {
30038         LDKClosingSigned this_ptr_conv;
30039         this_ptr_conv.inner = untag_ptr(this_ptr);
30040         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30042         this_ptr_conv.is_owned = false;
30043         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
30044         uint64_t ret_ref = 0;
30045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30046         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30047         return ret_ref;
30048 }
30049
30050 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint64_t this_ptr, uint64_t val) {
30051         LDKClosingSigned this_ptr_conv;
30052         this_ptr_conv.inner = untag_ptr(this_ptr);
30053         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30055         this_ptr_conv.is_owned = false;
30056         LDKClosingSignedFeeRange val_conv;
30057         val_conv.inner = untag_ptr(val);
30058         val_conv.is_owned = ptr_is_owned(val);
30059         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30060         val_conv = ClosingSignedFeeRange_clone(&val_conv);
30061         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
30062 }
30063
30064 uint64_t  __attribute__((export_name("TS_ClosingSigned_new"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg, uint64_t fee_range_arg) {
30065         LDKThirtyTwoBytes channel_id_arg_ref;
30066         CHECK(channel_id_arg->arr_len == 32);
30067         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30068         LDKSignature signature_arg_ref;
30069         CHECK(signature_arg->arr_len == 64);
30070         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30071         LDKClosingSignedFeeRange fee_range_arg_conv;
30072         fee_range_arg_conv.inner = untag_ptr(fee_range_arg);
30073         fee_range_arg_conv.is_owned = ptr_is_owned(fee_range_arg);
30074         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
30075         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
30076         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
30077         uint64_t ret_ref = 0;
30078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30079         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30080         return ret_ref;
30081 }
30082
30083 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
30084         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
30085         uint64_t ret_ref = 0;
30086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30087         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30088         return ret_ref;
30089 }
30090 int64_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint64_t arg) {
30091         LDKClosingSigned arg_conv;
30092         arg_conv.inner = untag_ptr(arg);
30093         arg_conv.is_owned = ptr_is_owned(arg);
30094         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30095         arg_conv.is_owned = false;
30096         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
30097         return ret_conv;
30098 }
30099
30100 uint64_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint64_t orig) {
30101         LDKClosingSigned orig_conv;
30102         orig_conv.inner = untag_ptr(orig);
30103         orig_conv.is_owned = ptr_is_owned(orig);
30104         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30105         orig_conv.is_owned = false;
30106         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
30107         uint64_t ret_ref = 0;
30108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30109         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30110         return ret_ref;
30111 }
30112
30113 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint64_t this_obj) {
30114         LDKUpdateAddHTLC this_obj_conv;
30115         this_obj_conv.inner = untag_ptr(this_obj);
30116         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30118         UpdateAddHTLC_free(this_obj_conv);
30119 }
30120
30121 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint64_t this_ptr) {
30122         LDKUpdateAddHTLC this_ptr_conv;
30123         this_ptr_conv.inner = untag_ptr(this_ptr);
30124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30126         this_ptr_conv.is_owned = false;
30127         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30128         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
30129         return ret_arr;
30130 }
30131
30132 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint64_t this_ptr, int8_tArray val) {
30133         LDKUpdateAddHTLC this_ptr_conv;
30134         this_ptr_conv.inner = untag_ptr(this_ptr);
30135         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30137         this_ptr_conv.is_owned = false;
30138         LDKThirtyTwoBytes val_ref;
30139         CHECK(val->arr_len == 32);
30140         memcpy(val_ref.data, val->elems, 32); FREE(val);
30141         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
30142 }
30143
30144 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint64_t this_ptr) {
30145         LDKUpdateAddHTLC this_ptr_conv;
30146         this_ptr_conv.inner = untag_ptr(this_ptr);
30147         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30149         this_ptr_conv.is_owned = false;
30150         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
30151         return ret_conv;
30152 }
30153
30154 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint64_t this_ptr, int64_t val) {
30155         LDKUpdateAddHTLC this_ptr_conv;
30156         this_ptr_conv.inner = untag_ptr(this_ptr);
30157         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30159         this_ptr_conv.is_owned = false;
30160         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
30161 }
30162
30163 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint64_t this_ptr) {
30164         LDKUpdateAddHTLC this_ptr_conv;
30165         this_ptr_conv.inner = untag_ptr(this_ptr);
30166         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30168         this_ptr_conv.is_owned = false;
30169         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
30170         return ret_conv;
30171 }
30172
30173 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint64_t this_ptr, int64_t val) {
30174         LDKUpdateAddHTLC this_ptr_conv;
30175         this_ptr_conv.inner = untag_ptr(this_ptr);
30176         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30178         this_ptr_conv.is_owned = false;
30179         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
30180 }
30181
30182 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint64_t this_ptr) {
30183         LDKUpdateAddHTLC this_ptr_conv;
30184         this_ptr_conv.inner = untag_ptr(this_ptr);
30185         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30187         this_ptr_conv.is_owned = false;
30188         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30189         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
30190         return ret_arr;
30191 }
30192
30193 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint64_t this_ptr, int8_tArray val) {
30194         LDKUpdateAddHTLC this_ptr_conv;
30195         this_ptr_conv.inner = untag_ptr(this_ptr);
30196         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30198         this_ptr_conv.is_owned = false;
30199         LDKThirtyTwoBytes val_ref;
30200         CHECK(val->arr_len == 32);
30201         memcpy(val_ref.data, val->elems, 32); FREE(val);
30202         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
30203 }
30204
30205 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint64_t this_ptr) {
30206         LDKUpdateAddHTLC this_ptr_conv;
30207         this_ptr_conv.inner = untag_ptr(this_ptr);
30208         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30210         this_ptr_conv.is_owned = false;
30211         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
30212         return ret_conv;
30213 }
30214
30215 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint64_t this_ptr, int32_t val) {
30216         LDKUpdateAddHTLC this_ptr_conv;
30217         this_ptr_conv.inner = untag_ptr(this_ptr);
30218         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30220         this_ptr_conv.is_owned = false;
30221         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
30222 }
30223
30224 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
30225         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
30226         uint64_t ret_ref = 0;
30227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30228         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30229         return ret_ref;
30230 }
30231 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint64_t arg) {
30232         LDKUpdateAddHTLC arg_conv;
30233         arg_conv.inner = untag_ptr(arg);
30234         arg_conv.is_owned = ptr_is_owned(arg);
30235         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30236         arg_conv.is_owned = false;
30237         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
30238         return ret_conv;
30239 }
30240
30241 uint64_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint64_t orig) {
30242         LDKUpdateAddHTLC orig_conv;
30243         orig_conv.inner = untag_ptr(orig);
30244         orig_conv.is_owned = ptr_is_owned(orig);
30245         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30246         orig_conv.is_owned = false;
30247         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
30248         uint64_t ret_ref = 0;
30249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30250         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30251         return ret_ref;
30252 }
30253
30254 void  __attribute__((export_name("TS_OnionMessage_free"))) TS_OnionMessage_free(uint64_t this_obj) {
30255         LDKOnionMessage this_obj_conv;
30256         this_obj_conv.inner = untag_ptr(this_obj);
30257         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30259         OnionMessage_free(this_obj_conv);
30260 }
30261
30262 int8_tArray  __attribute__((export_name("TS_OnionMessage_get_blinding_point"))) TS_OnionMessage_get_blinding_point(uint64_t this_ptr) {
30263         LDKOnionMessage this_ptr_conv;
30264         this_ptr_conv.inner = untag_ptr(this_ptr);
30265         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30267         this_ptr_conv.is_owned = false;
30268         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30269         memcpy(ret_arr->elems, OnionMessage_get_blinding_point(&this_ptr_conv).compressed_form, 33);
30270         return ret_arr;
30271 }
30272
30273 void  __attribute__((export_name("TS_OnionMessage_set_blinding_point"))) TS_OnionMessage_set_blinding_point(uint64_t this_ptr, int8_tArray val) {
30274         LDKOnionMessage this_ptr_conv;
30275         this_ptr_conv.inner = untag_ptr(this_ptr);
30276         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30278         this_ptr_conv.is_owned = false;
30279         LDKPublicKey val_ref;
30280         CHECK(val->arr_len == 33);
30281         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30282         OnionMessage_set_blinding_point(&this_ptr_conv, val_ref);
30283 }
30284
30285 static inline uint64_t OnionMessage_clone_ptr(LDKOnionMessage *NONNULL_PTR arg) {
30286         LDKOnionMessage ret_var = OnionMessage_clone(arg);
30287         uint64_t ret_ref = 0;
30288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30289         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30290         return ret_ref;
30291 }
30292 int64_t  __attribute__((export_name("TS_OnionMessage_clone_ptr"))) TS_OnionMessage_clone_ptr(uint64_t arg) {
30293         LDKOnionMessage arg_conv;
30294         arg_conv.inner = untag_ptr(arg);
30295         arg_conv.is_owned = ptr_is_owned(arg);
30296         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30297         arg_conv.is_owned = false;
30298         int64_t ret_conv = OnionMessage_clone_ptr(&arg_conv);
30299         return ret_conv;
30300 }
30301
30302 uint64_t  __attribute__((export_name("TS_OnionMessage_clone"))) TS_OnionMessage_clone(uint64_t orig) {
30303         LDKOnionMessage orig_conv;
30304         orig_conv.inner = untag_ptr(orig);
30305         orig_conv.is_owned = ptr_is_owned(orig);
30306         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30307         orig_conv.is_owned = false;
30308         LDKOnionMessage ret_var = OnionMessage_clone(&orig_conv);
30309         uint64_t ret_ref = 0;
30310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30311         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30312         return ret_ref;
30313 }
30314
30315 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint64_t this_obj) {
30316         LDKUpdateFulfillHTLC this_obj_conv;
30317         this_obj_conv.inner = untag_ptr(this_obj);
30318         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30320         UpdateFulfillHTLC_free(this_obj_conv);
30321 }
30322
30323 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint64_t this_ptr) {
30324         LDKUpdateFulfillHTLC this_ptr_conv;
30325         this_ptr_conv.inner = untag_ptr(this_ptr);
30326         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30328         this_ptr_conv.is_owned = false;
30329         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30330         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
30331         return ret_arr;
30332 }
30333
30334 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint64_t this_ptr, int8_tArray val) {
30335         LDKUpdateFulfillHTLC this_ptr_conv;
30336         this_ptr_conv.inner = untag_ptr(this_ptr);
30337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30339         this_ptr_conv.is_owned = false;
30340         LDKThirtyTwoBytes val_ref;
30341         CHECK(val->arr_len == 32);
30342         memcpy(val_ref.data, val->elems, 32); FREE(val);
30343         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
30344 }
30345
30346 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint64_t this_ptr) {
30347         LDKUpdateFulfillHTLC this_ptr_conv;
30348         this_ptr_conv.inner = untag_ptr(this_ptr);
30349         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30351         this_ptr_conv.is_owned = false;
30352         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
30353         return ret_conv;
30354 }
30355
30356 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint64_t this_ptr, int64_t val) {
30357         LDKUpdateFulfillHTLC this_ptr_conv;
30358         this_ptr_conv.inner = untag_ptr(this_ptr);
30359         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30361         this_ptr_conv.is_owned = false;
30362         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
30363 }
30364
30365 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint64_t this_ptr) {
30366         LDKUpdateFulfillHTLC this_ptr_conv;
30367         this_ptr_conv.inner = untag_ptr(this_ptr);
30368         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30370         this_ptr_conv.is_owned = false;
30371         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30372         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
30373         return ret_arr;
30374 }
30375
30376 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint64_t this_ptr, int8_tArray val) {
30377         LDKUpdateFulfillHTLC this_ptr_conv;
30378         this_ptr_conv.inner = untag_ptr(this_ptr);
30379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30381         this_ptr_conv.is_owned = false;
30382         LDKThirtyTwoBytes val_ref;
30383         CHECK(val->arr_len == 32);
30384         memcpy(val_ref.data, val->elems, 32); FREE(val);
30385         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
30386 }
30387
30388 uint64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_new"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
30389         LDKThirtyTwoBytes channel_id_arg_ref;
30390         CHECK(channel_id_arg->arr_len == 32);
30391         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30392         LDKThirtyTwoBytes payment_preimage_arg_ref;
30393         CHECK(payment_preimage_arg->arr_len == 32);
30394         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
30395         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
30396         uint64_t ret_ref = 0;
30397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30398         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30399         return ret_ref;
30400 }
30401
30402 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
30403         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
30404         uint64_t ret_ref = 0;
30405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30406         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30407         return ret_ref;
30408 }
30409 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint64_t arg) {
30410         LDKUpdateFulfillHTLC arg_conv;
30411         arg_conv.inner = untag_ptr(arg);
30412         arg_conv.is_owned = ptr_is_owned(arg);
30413         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30414         arg_conv.is_owned = false;
30415         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
30416         return ret_conv;
30417 }
30418
30419 uint64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint64_t orig) {
30420         LDKUpdateFulfillHTLC orig_conv;
30421         orig_conv.inner = untag_ptr(orig);
30422         orig_conv.is_owned = ptr_is_owned(orig);
30423         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30424         orig_conv.is_owned = false;
30425         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
30426         uint64_t ret_ref = 0;
30427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30428         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30429         return ret_ref;
30430 }
30431
30432 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint64_t this_obj) {
30433         LDKUpdateFailHTLC this_obj_conv;
30434         this_obj_conv.inner = untag_ptr(this_obj);
30435         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30437         UpdateFailHTLC_free(this_obj_conv);
30438 }
30439
30440 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint64_t this_ptr) {
30441         LDKUpdateFailHTLC this_ptr_conv;
30442         this_ptr_conv.inner = untag_ptr(this_ptr);
30443         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30445         this_ptr_conv.is_owned = false;
30446         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30447         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
30448         return ret_arr;
30449 }
30450
30451 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint64_t this_ptr, int8_tArray val) {
30452         LDKUpdateFailHTLC this_ptr_conv;
30453         this_ptr_conv.inner = untag_ptr(this_ptr);
30454         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30456         this_ptr_conv.is_owned = false;
30457         LDKThirtyTwoBytes val_ref;
30458         CHECK(val->arr_len == 32);
30459         memcpy(val_ref.data, val->elems, 32); FREE(val);
30460         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
30461 }
30462
30463 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint64_t this_ptr) {
30464         LDKUpdateFailHTLC this_ptr_conv;
30465         this_ptr_conv.inner = untag_ptr(this_ptr);
30466         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30468         this_ptr_conv.is_owned = false;
30469         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
30470         return ret_conv;
30471 }
30472
30473 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint64_t this_ptr, int64_t val) {
30474         LDKUpdateFailHTLC this_ptr_conv;
30475         this_ptr_conv.inner = untag_ptr(this_ptr);
30476         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30478         this_ptr_conv.is_owned = false;
30479         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
30480 }
30481
30482 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
30483         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
30484         uint64_t ret_ref = 0;
30485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30486         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30487         return ret_ref;
30488 }
30489 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint64_t arg) {
30490         LDKUpdateFailHTLC arg_conv;
30491         arg_conv.inner = untag_ptr(arg);
30492         arg_conv.is_owned = ptr_is_owned(arg);
30493         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30494         arg_conv.is_owned = false;
30495         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
30496         return ret_conv;
30497 }
30498
30499 uint64_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint64_t orig) {
30500         LDKUpdateFailHTLC orig_conv;
30501         orig_conv.inner = untag_ptr(orig);
30502         orig_conv.is_owned = ptr_is_owned(orig);
30503         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30504         orig_conv.is_owned = false;
30505         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
30506         uint64_t ret_ref = 0;
30507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30509         return ret_ref;
30510 }
30511
30512 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint64_t this_obj) {
30513         LDKUpdateFailMalformedHTLC this_obj_conv;
30514         this_obj_conv.inner = untag_ptr(this_obj);
30515         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30517         UpdateFailMalformedHTLC_free(this_obj_conv);
30518 }
30519
30520 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint64_t this_ptr) {
30521         LDKUpdateFailMalformedHTLC this_ptr_conv;
30522         this_ptr_conv.inner = untag_ptr(this_ptr);
30523         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30525         this_ptr_conv.is_owned = false;
30526         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30527         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
30528         return ret_arr;
30529 }
30530
30531 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint64_t this_ptr, int8_tArray val) {
30532         LDKUpdateFailMalformedHTLC this_ptr_conv;
30533         this_ptr_conv.inner = untag_ptr(this_ptr);
30534         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30536         this_ptr_conv.is_owned = false;
30537         LDKThirtyTwoBytes val_ref;
30538         CHECK(val->arr_len == 32);
30539         memcpy(val_ref.data, val->elems, 32); FREE(val);
30540         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
30541 }
30542
30543 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint64_t this_ptr) {
30544         LDKUpdateFailMalformedHTLC this_ptr_conv;
30545         this_ptr_conv.inner = untag_ptr(this_ptr);
30546         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30548         this_ptr_conv.is_owned = false;
30549         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
30550         return ret_conv;
30551 }
30552
30553 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint64_t this_ptr, int64_t val) {
30554         LDKUpdateFailMalformedHTLC this_ptr_conv;
30555         this_ptr_conv.inner = untag_ptr(this_ptr);
30556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30558         this_ptr_conv.is_owned = false;
30559         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
30560 }
30561
30562 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint64_t this_ptr) {
30563         LDKUpdateFailMalformedHTLC this_ptr_conv;
30564         this_ptr_conv.inner = untag_ptr(this_ptr);
30565         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30567         this_ptr_conv.is_owned = false;
30568         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
30569         return ret_conv;
30570 }
30571
30572 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint64_t this_ptr, int16_t val) {
30573         LDKUpdateFailMalformedHTLC this_ptr_conv;
30574         this_ptr_conv.inner = untag_ptr(this_ptr);
30575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30577         this_ptr_conv.is_owned = false;
30578         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
30579 }
30580
30581 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
30582         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
30583         uint64_t ret_ref = 0;
30584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30585         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30586         return ret_ref;
30587 }
30588 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint64_t arg) {
30589         LDKUpdateFailMalformedHTLC arg_conv;
30590         arg_conv.inner = untag_ptr(arg);
30591         arg_conv.is_owned = ptr_is_owned(arg);
30592         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30593         arg_conv.is_owned = false;
30594         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
30595         return ret_conv;
30596 }
30597
30598 uint64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint64_t orig) {
30599         LDKUpdateFailMalformedHTLC orig_conv;
30600         orig_conv.inner = untag_ptr(orig);
30601         orig_conv.is_owned = ptr_is_owned(orig);
30602         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30603         orig_conv.is_owned = false;
30604         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
30605         uint64_t ret_ref = 0;
30606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30607         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30608         return ret_ref;
30609 }
30610
30611 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint64_t this_obj) {
30612         LDKCommitmentSigned this_obj_conv;
30613         this_obj_conv.inner = untag_ptr(this_obj);
30614         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30616         CommitmentSigned_free(this_obj_conv);
30617 }
30618
30619 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint64_t this_ptr) {
30620         LDKCommitmentSigned this_ptr_conv;
30621         this_ptr_conv.inner = untag_ptr(this_ptr);
30622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30624         this_ptr_conv.is_owned = false;
30625         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30626         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
30627         return ret_arr;
30628 }
30629
30630 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint64_t this_ptr, int8_tArray val) {
30631         LDKCommitmentSigned this_ptr_conv;
30632         this_ptr_conv.inner = untag_ptr(this_ptr);
30633         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30635         this_ptr_conv.is_owned = false;
30636         LDKThirtyTwoBytes val_ref;
30637         CHECK(val->arr_len == 32);
30638         memcpy(val_ref.data, val->elems, 32); FREE(val);
30639         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
30640 }
30641
30642 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint64_t this_ptr) {
30643         LDKCommitmentSigned this_ptr_conv;
30644         this_ptr_conv.inner = untag_ptr(this_ptr);
30645         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30647         this_ptr_conv.is_owned = false;
30648         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30649         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
30650         return ret_arr;
30651 }
30652
30653 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint64_t this_ptr, int8_tArray val) {
30654         LDKCommitmentSigned this_ptr_conv;
30655         this_ptr_conv.inner = untag_ptr(this_ptr);
30656         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30658         this_ptr_conv.is_owned = false;
30659         LDKSignature val_ref;
30660         CHECK(val->arr_len == 64);
30661         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30662         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
30663 }
30664
30665 ptrArray  __attribute__((export_name("TS_CommitmentSigned_get_htlc_signatures"))) TS_CommitmentSigned_get_htlc_signatures(uint64_t this_ptr) {
30666         LDKCommitmentSigned this_ptr_conv;
30667         this_ptr_conv.inner = untag_ptr(this_ptr);
30668         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30670         this_ptr_conv.is_owned = false;
30671         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
30672         ptrArray ret_arr = NULL;
30673         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
30674         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
30675         for (size_t m = 0; m < ret_var.datalen; m++) {
30676                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
30677                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
30678                 ret_arr_ptr[m] = ret_conv_12_arr;
30679         }
30680         
30681         FREE(ret_var.data);
30682         return ret_arr;
30683 }
30684
30685 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint64_t this_ptr, ptrArray val) {
30686         LDKCommitmentSigned this_ptr_conv;
30687         this_ptr_conv.inner = untag_ptr(this_ptr);
30688         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30690         this_ptr_conv.is_owned = false;
30691         LDKCVec_SignatureZ val_constr;
30692         val_constr.datalen = val->arr_len;
30693         if (val_constr.datalen > 0)
30694                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30695         else
30696                 val_constr.data = NULL;
30697         int8_tArray* val_vals = (void*) val->elems;
30698         for (size_t m = 0; m < val_constr.datalen; m++) {
30699                 int8_tArray val_conv_12 = val_vals[m];
30700                 LDKSignature val_conv_12_ref;
30701                 CHECK(val_conv_12->arr_len == 64);
30702                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
30703                 val_constr.data[m] = val_conv_12_ref;
30704         }
30705         FREE(val);
30706         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
30707 }
30708
30709 uint64_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
30710         LDKThirtyTwoBytes channel_id_arg_ref;
30711         CHECK(channel_id_arg->arr_len == 32);
30712         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30713         LDKSignature signature_arg_ref;
30714         CHECK(signature_arg->arr_len == 64);
30715         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30716         LDKCVec_SignatureZ htlc_signatures_arg_constr;
30717         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
30718         if (htlc_signatures_arg_constr.datalen > 0)
30719                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30720         else
30721                 htlc_signatures_arg_constr.data = NULL;
30722         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems;
30723         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
30724                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
30725                 LDKSignature htlc_signatures_arg_conv_12_ref;
30726                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
30727                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
30728                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
30729         }
30730         FREE(htlc_signatures_arg);
30731         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
30732         uint64_t ret_ref = 0;
30733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30735         return ret_ref;
30736 }
30737
30738 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
30739         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
30740         uint64_t ret_ref = 0;
30741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30742         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30743         return ret_ref;
30744 }
30745 int64_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint64_t arg) {
30746         LDKCommitmentSigned arg_conv;
30747         arg_conv.inner = untag_ptr(arg);
30748         arg_conv.is_owned = ptr_is_owned(arg);
30749         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30750         arg_conv.is_owned = false;
30751         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
30752         return ret_conv;
30753 }
30754
30755 uint64_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint64_t orig) {
30756         LDKCommitmentSigned orig_conv;
30757         orig_conv.inner = untag_ptr(orig);
30758         orig_conv.is_owned = ptr_is_owned(orig);
30759         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30760         orig_conv.is_owned = false;
30761         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
30762         uint64_t ret_ref = 0;
30763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30764         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30765         return ret_ref;
30766 }
30767
30768 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint64_t this_obj) {
30769         LDKRevokeAndACK this_obj_conv;
30770         this_obj_conv.inner = untag_ptr(this_obj);
30771         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30773         RevokeAndACK_free(this_obj_conv);
30774 }
30775
30776 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint64_t this_ptr) {
30777         LDKRevokeAndACK this_ptr_conv;
30778         this_ptr_conv.inner = untag_ptr(this_ptr);
30779         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30781         this_ptr_conv.is_owned = false;
30782         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30783         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
30784         return ret_arr;
30785 }
30786
30787 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint64_t this_ptr, int8_tArray val) {
30788         LDKRevokeAndACK this_ptr_conv;
30789         this_ptr_conv.inner = untag_ptr(this_ptr);
30790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30792         this_ptr_conv.is_owned = false;
30793         LDKThirtyTwoBytes val_ref;
30794         CHECK(val->arr_len == 32);
30795         memcpy(val_ref.data, val->elems, 32); FREE(val);
30796         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
30797 }
30798
30799 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint64_t this_ptr) {
30800         LDKRevokeAndACK this_ptr_conv;
30801         this_ptr_conv.inner = untag_ptr(this_ptr);
30802         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30804         this_ptr_conv.is_owned = false;
30805         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30806         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
30807         return ret_arr;
30808 }
30809
30810 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint64_t this_ptr, int8_tArray val) {
30811         LDKRevokeAndACK this_ptr_conv;
30812         this_ptr_conv.inner = untag_ptr(this_ptr);
30813         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30815         this_ptr_conv.is_owned = false;
30816         LDKThirtyTwoBytes val_ref;
30817         CHECK(val->arr_len == 32);
30818         memcpy(val_ref.data, val->elems, 32); FREE(val);
30819         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
30820 }
30821
30822 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint64_t this_ptr) {
30823         LDKRevokeAndACK this_ptr_conv;
30824         this_ptr_conv.inner = untag_ptr(this_ptr);
30825         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30827         this_ptr_conv.is_owned = false;
30828         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30829         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
30830         return ret_arr;
30831 }
30832
30833 void  __attribute__((export_name("TS_RevokeAndACK_set_next_per_commitment_point"))) TS_RevokeAndACK_set_next_per_commitment_point(uint64_t this_ptr, int8_tArray val) {
30834         LDKRevokeAndACK this_ptr_conv;
30835         this_ptr_conv.inner = untag_ptr(this_ptr);
30836         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30838         this_ptr_conv.is_owned = false;
30839         LDKPublicKey val_ref;
30840         CHECK(val->arr_len == 33);
30841         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30842         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
30843 }
30844
30845 uint64_t  __attribute__((export_name("TS_RevokeAndACK_new"))) TS_RevokeAndACK_new(int8_tArray channel_id_arg, int8_tArray per_commitment_secret_arg, int8_tArray next_per_commitment_point_arg) {
30846         LDKThirtyTwoBytes channel_id_arg_ref;
30847         CHECK(channel_id_arg->arr_len == 32);
30848         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30849         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
30850         CHECK(per_commitment_secret_arg->arr_len == 32);
30851         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
30852         LDKPublicKey next_per_commitment_point_arg_ref;
30853         CHECK(next_per_commitment_point_arg->arr_len == 33);
30854         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
30855         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
30856         uint64_t ret_ref = 0;
30857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30858         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30859         return ret_ref;
30860 }
30861
30862 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
30863         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
30864         uint64_t ret_ref = 0;
30865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30866         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30867         return ret_ref;
30868 }
30869 int64_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint64_t arg) {
30870         LDKRevokeAndACK arg_conv;
30871         arg_conv.inner = untag_ptr(arg);
30872         arg_conv.is_owned = ptr_is_owned(arg);
30873         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30874         arg_conv.is_owned = false;
30875         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
30876         return ret_conv;
30877 }
30878
30879 uint64_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint64_t orig) {
30880         LDKRevokeAndACK orig_conv;
30881         orig_conv.inner = untag_ptr(orig);
30882         orig_conv.is_owned = ptr_is_owned(orig);
30883         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30884         orig_conv.is_owned = false;
30885         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
30886         uint64_t ret_ref = 0;
30887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30888         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30889         return ret_ref;
30890 }
30891
30892 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint64_t this_obj) {
30893         LDKUpdateFee this_obj_conv;
30894         this_obj_conv.inner = untag_ptr(this_obj);
30895         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30897         UpdateFee_free(this_obj_conv);
30898 }
30899
30900 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint64_t this_ptr) {
30901         LDKUpdateFee this_ptr_conv;
30902         this_ptr_conv.inner = untag_ptr(this_ptr);
30903         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30905         this_ptr_conv.is_owned = false;
30906         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30907         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
30908         return ret_arr;
30909 }
30910
30911 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint64_t this_ptr, int8_tArray val) {
30912         LDKUpdateFee this_ptr_conv;
30913         this_ptr_conv.inner = untag_ptr(this_ptr);
30914         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30916         this_ptr_conv.is_owned = false;
30917         LDKThirtyTwoBytes val_ref;
30918         CHECK(val->arr_len == 32);
30919         memcpy(val_ref.data, val->elems, 32); FREE(val);
30920         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
30921 }
30922
30923 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint64_t this_ptr) {
30924         LDKUpdateFee this_ptr_conv;
30925         this_ptr_conv.inner = untag_ptr(this_ptr);
30926         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30928         this_ptr_conv.is_owned = false;
30929         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
30930         return ret_conv;
30931 }
30932
30933 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint64_t this_ptr, int32_t val) {
30934         LDKUpdateFee this_ptr_conv;
30935         this_ptr_conv.inner = untag_ptr(this_ptr);
30936         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30938         this_ptr_conv.is_owned = false;
30939         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
30940 }
30941
30942 uint64_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
30943         LDKThirtyTwoBytes channel_id_arg_ref;
30944         CHECK(channel_id_arg->arr_len == 32);
30945         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30946         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
30947         uint64_t ret_ref = 0;
30948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30949         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30950         return ret_ref;
30951 }
30952
30953 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
30954         LDKUpdateFee ret_var = UpdateFee_clone(arg);
30955         uint64_t ret_ref = 0;
30956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30957         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30958         return ret_ref;
30959 }
30960 int64_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint64_t arg) {
30961         LDKUpdateFee arg_conv;
30962         arg_conv.inner = untag_ptr(arg);
30963         arg_conv.is_owned = ptr_is_owned(arg);
30964         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30965         arg_conv.is_owned = false;
30966         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
30967         return ret_conv;
30968 }
30969
30970 uint64_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint64_t orig) {
30971         LDKUpdateFee orig_conv;
30972         orig_conv.inner = untag_ptr(orig);
30973         orig_conv.is_owned = ptr_is_owned(orig);
30974         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30975         orig_conv.is_owned = false;
30976         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
30977         uint64_t ret_ref = 0;
30978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30979         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30980         return ret_ref;
30981 }
30982
30983 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint64_t this_obj) {
30984         LDKDataLossProtect this_obj_conv;
30985         this_obj_conv.inner = untag_ptr(this_obj);
30986         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30988         DataLossProtect_free(this_obj_conv);
30989 }
30990
30991 int8_tArray  __attribute__((export_name("TS_DataLossProtect_get_your_last_per_commitment_secret"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint64_t this_ptr) {
30992         LDKDataLossProtect this_ptr_conv;
30993         this_ptr_conv.inner = untag_ptr(this_ptr);
30994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30996         this_ptr_conv.is_owned = false;
30997         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30998         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
30999         return ret_arr;
31000 }
31001
31002 void  __attribute__((export_name("TS_DataLossProtect_set_your_last_per_commitment_secret"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint64_t this_ptr, int8_tArray val) {
31003         LDKDataLossProtect this_ptr_conv;
31004         this_ptr_conv.inner = untag_ptr(this_ptr);
31005         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31007         this_ptr_conv.is_owned = false;
31008         LDKThirtyTwoBytes val_ref;
31009         CHECK(val->arr_len == 32);
31010         memcpy(val_ref.data, val->elems, 32); FREE(val);
31011         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
31012 }
31013
31014 int8_tArray  __attribute__((export_name("TS_DataLossProtect_get_my_current_per_commitment_point"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint64_t this_ptr) {
31015         LDKDataLossProtect this_ptr_conv;
31016         this_ptr_conv.inner = untag_ptr(this_ptr);
31017         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31019         this_ptr_conv.is_owned = false;
31020         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31021         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
31022         return ret_arr;
31023 }
31024
31025 void  __attribute__((export_name("TS_DataLossProtect_set_my_current_per_commitment_point"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint64_t this_ptr, int8_tArray val) {
31026         LDKDataLossProtect this_ptr_conv;
31027         this_ptr_conv.inner = untag_ptr(this_ptr);
31028         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31030         this_ptr_conv.is_owned = false;
31031         LDKPublicKey val_ref;
31032         CHECK(val->arr_len == 33);
31033         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31034         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
31035 }
31036
31037 uint64_t  __attribute__((export_name("TS_DataLossProtect_new"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
31038         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
31039         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
31040         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
31041         LDKPublicKey my_current_per_commitment_point_arg_ref;
31042         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
31043         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, my_current_per_commitment_point_arg->elems, 33); FREE(my_current_per_commitment_point_arg);
31044         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
31045         uint64_t ret_ref = 0;
31046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31047         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31048         return ret_ref;
31049 }
31050
31051 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
31052         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
31053         uint64_t ret_ref = 0;
31054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31055         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31056         return ret_ref;
31057 }
31058 int64_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint64_t arg) {
31059         LDKDataLossProtect arg_conv;
31060         arg_conv.inner = untag_ptr(arg);
31061         arg_conv.is_owned = ptr_is_owned(arg);
31062         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31063         arg_conv.is_owned = false;
31064         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
31065         return ret_conv;
31066 }
31067
31068 uint64_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint64_t orig) {
31069         LDKDataLossProtect orig_conv;
31070         orig_conv.inner = untag_ptr(orig);
31071         orig_conv.is_owned = ptr_is_owned(orig);
31072         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31073         orig_conv.is_owned = false;
31074         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
31075         uint64_t ret_ref = 0;
31076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31078         return ret_ref;
31079 }
31080
31081 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint64_t this_obj) {
31082         LDKChannelReestablish this_obj_conv;
31083         this_obj_conv.inner = untag_ptr(this_obj);
31084         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31086         ChannelReestablish_free(this_obj_conv);
31087 }
31088
31089 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint64_t this_ptr) {
31090         LDKChannelReestablish this_ptr_conv;
31091         this_ptr_conv.inner = untag_ptr(this_ptr);
31092         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31094         this_ptr_conv.is_owned = false;
31095         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31096         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
31097         return ret_arr;
31098 }
31099
31100 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint64_t this_ptr, int8_tArray val) {
31101         LDKChannelReestablish this_ptr_conv;
31102         this_ptr_conv.inner = untag_ptr(this_ptr);
31103         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31105         this_ptr_conv.is_owned = false;
31106         LDKThirtyTwoBytes val_ref;
31107         CHECK(val->arr_len == 32);
31108         memcpy(val_ref.data, val->elems, 32); FREE(val);
31109         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
31110 }
31111
31112 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint64_t this_ptr) {
31113         LDKChannelReestablish this_ptr_conv;
31114         this_ptr_conv.inner = untag_ptr(this_ptr);
31115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31117         this_ptr_conv.is_owned = false;
31118         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
31119         return ret_conv;
31120 }
31121
31122 void  __attribute__((export_name("TS_ChannelReestablish_set_next_local_commitment_number"))) TS_ChannelReestablish_set_next_local_commitment_number(uint64_t this_ptr, int64_t val) {
31123         LDKChannelReestablish this_ptr_conv;
31124         this_ptr_conv.inner = untag_ptr(this_ptr);
31125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31127         this_ptr_conv.is_owned = false;
31128         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
31129 }
31130
31131 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint64_t this_ptr) {
31132         LDKChannelReestablish this_ptr_conv;
31133         this_ptr_conv.inner = untag_ptr(this_ptr);
31134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31136         this_ptr_conv.is_owned = false;
31137         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
31138         return ret_conv;
31139 }
31140
31141 void  __attribute__((export_name("TS_ChannelReestablish_set_next_remote_commitment_number"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint64_t this_ptr, int64_t val) {
31142         LDKChannelReestablish this_ptr_conv;
31143         this_ptr_conv.inner = untag_ptr(this_ptr);
31144         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31146         this_ptr_conv.is_owned = false;
31147         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
31148 }
31149
31150 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
31151         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
31152         uint64_t ret_ref = 0;
31153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31154         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31155         return ret_ref;
31156 }
31157 int64_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint64_t arg) {
31158         LDKChannelReestablish arg_conv;
31159         arg_conv.inner = untag_ptr(arg);
31160         arg_conv.is_owned = ptr_is_owned(arg);
31161         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31162         arg_conv.is_owned = false;
31163         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
31164         return ret_conv;
31165 }
31166
31167 uint64_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint64_t orig) {
31168         LDKChannelReestablish orig_conv;
31169         orig_conv.inner = untag_ptr(orig);
31170         orig_conv.is_owned = ptr_is_owned(orig);
31171         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31172         orig_conv.is_owned = false;
31173         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
31174         uint64_t ret_ref = 0;
31175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31176         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31177         return ret_ref;
31178 }
31179
31180 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint64_t this_obj) {
31181         LDKAnnouncementSignatures this_obj_conv;
31182         this_obj_conv.inner = untag_ptr(this_obj);
31183         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31185         AnnouncementSignatures_free(this_obj_conv);
31186 }
31187
31188 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint64_t this_ptr) {
31189         LDKAnnouncementSignatures this_ptr_conv;
31190         this_ptr_conv.inner = untag_ptr(this_ptr);
31191         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31193         this_ptr_conv.is_owned = false;
31194         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31195         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
31196         return ret_arr;
31197 }
31198
31199 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint64_t this_ptr, int8_tArray val) {
31200         LDKAnnouncementSignatures this_ptr_conv;
31201         this_ptr_conv.inner = untag_ptr(this_ptr);
31202         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31204         this_ptr_conv.is_owned = false;
31205         LDKThirtyTwoBytes val_ref;
31206         CHECK(val->arr_len == 32);
31207         memcpy(val_ref.data, val->elems, 32); FREE(val);
31208         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
31209 }
31210
31211 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint64_t this_ptr) {
31212         LDKAnnouncementSignatures this_ptr_conv;
31213         this_ptr_conv.inner = untag_ptr(this_ptr);
31214         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31216         this_ptr_conv.is_owned = false;
31217         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
31218         return ret_conv;
31219 }
31220
31221 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint64_t this_ptr, int64_t val) {
31222         LDKAnnouncementSignatures this_ptr_conv;
31223         this_ptr_conv.inner = untag_ptr(this_ptr);
31224         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31226         this_ptr_conv.is_owned = false;
31227         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
31228 }
31229
31230 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint64_t this_ptr) {
31231         LDKAnnouncementSignatures this_ptr_conv;
31232         this_ptr_conv.inner = untag_ptr(this_ptr);
31233         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31235         this_ptr_conv.is_owned = false;
31236         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31237         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
31238         return ret_arr;
31239 }
31240
31241 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint64_t this_ptr, int8_tArray val) {
31242         LDKAnnouncementSignatures this_ptr_conv;
31243         this_ptr_conv.inner = untag_ptr(this_ptr);
31244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31246         this_ptr_conv.is_owned = false;
31247         LDKSignature val_ref;
31248         CHECK(val->arr_len == 64);
31249         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31250         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
31251 }
31252
31253 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint64_t this_ptr) {
31254         LDKAnnouncementSignatures this_ptr_conv;
31255         this_ptr_conv.inner = untag_ptr(this_ptr);
31256         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31258         this_ptr_conv.is_owned = false;
31259         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31260         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
31261         return ret_arr;
31262 }
31263
31264 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint64_t this_ptr, int8_tArray val) {
31265         LDKAnnouncementSignatures this_ptr_conv;
31266         this_ptr_conv.inner = untag_ptr(this_ptr);
31267         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31269         this_ptr_conv.is_owned = false;
31270         LDKSignature val_ref;
31271         CHECK(val->arr_len == 64);
31272         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31273         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
31274 }
31275
31276 uint64_t  __attribute__((export_name("TS_AnnouncementSignatures_new"))) TS_AnnouncementSignatures_new(int8_tArray channel_id_arg, int64_t short_channel_id_arg, int8_tArray node_signature_arg, int8_tArray bitcoin_signature_arg) {
31277         LDKThirtyTwoBytes channel_id_arg_ref;
31278         CHECK(channel_id_arg->arr_len == 32);
31279         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
31280         LDKSignature node_signature_arg_ref;
31281         CHECK(node_signature_arg->arr_len == 64);
31282         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
31283         LDKSignature bitcoin_signature_arg_ref;
31284         CHECK(bitcoin_signature_arg->arr_len == 64);
31285         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
31286         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
31287         uint64_t ret_ref = 0;
31288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31289         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31290         return ret_ref;
31291 }
31292
31293 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
31294         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
31295         uint64_t ret_ref = 0;
31296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31297         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31298         return ret_ref;
31299 }
31300 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint64_t arg) {
31301         LDKAnnouncementSignatures arg_conv;
31302         arg_conv.inner = untag_ptr(arg);
31303         arg_conv.is_owned = ptr_is_owned(arg);
31304         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31305         arg_conv.is_owned = false;
31306         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
31307         return ret_conv;
31308 }
31309
31310 uint64_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint64_t orig) {
31311         LDKAnnouncementSignatures orig_conv;
31312         orig_conv.inner = untag_ptr(orig);
31313         orig_conv.is_owned = ptr_is_owned(orig);
31314         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31315         orig_conv.is_owned = false;
31316         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
31317         uint64_t ret_ref = 0;
31318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31319         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31320         return ret_ref;
31321 }
31322
31323 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint64_t this_ptr) {
31324         if (!ptr_is_owned(this_ptr)) return;
31325         void* this_ptr_ptr = untag_ptr(this_ptr);
31326         CHECK_ACCESS(this_ptr_ptr);
31327         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
31328         FREE(untag_ptr(this_ptr));
31329         NetAddress_free(this_ptr_conv);
31330 }
31331
31332 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
31333         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31334         *ret_copy = NetAddress_clone(arg);
31335         uint64_t ret_ref = tag_ptr(ret_copy, true);
31336         return ret_ref;
31337 }
31338 int64_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint64_t arg) {
31339         LDKNetAddress* arg_conv = (LDKNetAddress*)untag_ptr(arg);
31340         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
31341         return ret_conv;
31342 }
31343
31344 uint64_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint64_t orig) {
31345         LDKNetAddress* orig_conv = (LDKNetAddress*)untag_ptr(orig);
31346         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31347         *ret_copy = NetAddress_clone(orig_conv);
31348         uint64_t ret_ref = tag_ptr(ret_copy, true);
31349         return ret_ref;
31350 }
31351
31352 uint64_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
31353         LDKFourBytes addr_ref;
31354         CHECK(addr->arr_len == 4);
31355         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
31356         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31357         *ret_copy = NetAddress_ipv4(addr_ref, port);
31358         uint64_t ret_ref = tag_ptr(ret_copy, true);
31359         return ret_ref;
31360 }
31361
31362 uint64_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
31363         LDKSixteenBytes addr_ref;
31364         CHECK(addr->arr_len == 16);
31365         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
31366         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31367         *ret_copy = NetAddress_ipv6(addr_ref, port);
31368         uint64_t ret_ref = tag_ptr(ret_copy, true);
31369         return ret_ref;
31370 }
31371
31372 uint64_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
31373         LDKTwelveBytes a_ref;
31374         CHECK(a->arr_len == 12);
31375         memcpy(a_ref.data, a->elems, 12); FREE(a);
31376         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31377         *ret_copy = NetAddress_onion_v2(a_ref);
31378         uint64_t ret_ref = tag_ptr(ret_copy, true);
31379         return ret_ref;
31380 }
31381
31382 uint64_t  __attribute__((export_name("TS_NetAddress_onion_v3"))) TS_NetAddress_onion_v3(int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
31383         LDKThirtyTwoBytes ed25519_pubkey_ref;
31384         CHECK(ed25519_pubkey->arr_len == 32);
31385         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
31386         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31387         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
31388         uint64_t ret_ref = tag_ptr(ret_copy, true);
31389         return ret_ref;
31390 }
31391
31392 uint64_t  __attribute__((export_name("TS_NetAddress_hostname"))) TS_NetAddress_hostname(uint64_t hostname, int16_t port) {
31393         LDKHostname hostname_conv;
31394         hostname_conv.inner = untag_ptr(hostname);
31395         hostname_conv.is_owned = ptr_is_owned(hostname);
31396         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
31397         hostname_conv = Hostname_clone(&hostname_conv);
31398         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31399         *ret_copy = NetAddress_hostname(hostname_conv, port);
31400         uint64_t ret_ref = tag_ptr(ret_copy, true);
31401         return ret_ref;
31402 }
31403
31404 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint64_t obj) {
31405         LDKNetAddress* obj_conv = (LDKNetAddress*)untag_ptr(obj);
31406         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
31407         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31408         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31409         CVec_u8Z_free(ret_var);
31410         return ret_arr;
31411 }
31412
31413 uint64_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
31414         LDKu8slice ser_ref;
31415         ser_ref.datalen = ser->arr_len;
31416         ser_ref.data = ser->elems;
31417         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
31418         *ret_conv = NetAddress_read(ser_ref);
31419         FREE(ser);
31420         return tag_ptr(ret_conv, true);
31421 }
31422
31423 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint64_t this_obj) {
31424         LDKUnsignedNodeAnnouncement this_obj_conv;
31425         this_obj_conv.inner = untag_ptr(this_obj);
31426         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31428         UnsignedNodeAnnouncement_free(this_obj_conv);
31429 }
31430
31431 uint64_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint64_t this_ptr) {
31432         LDKUnsignedNodeAnnouncement this_ptr_conv;
31433         this_ptr_conv.inner = untag_ptr(this_ptr);
31434         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31436         this_ptr_conv.is_owned = false;
31437         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
31438         uint64_t ret_ref = 0;
31439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31440         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31441         return ret_ref;
31442 }
31443
31444 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint64_t this_ptr, uint64_t val) {
31445         LDKUnsignedNodeAnnouncement this_ptr_conv;
31446         this_ptr_conv.inner = untag_ptr(this_ptr);
31447         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31449         this_ptr_conv.is_owned = false;
31450         LDKNodeFeatures val_conv;
31451         val_conv.inner = untag_ptr(val);
31452         val_conv.is_owned = ptr_is_owned(val);
31453         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31454         val_conv = NodeFeatures_clone(&val_conv);
31455         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
31456 }
31457
31458 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint64_t this_ptr) {
31459         LDKUnsignedNodeAnnouncement this_ptr_conv;
31460         this_ptr_conv.inner = untag_ptr(this_ptr);
31461         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31463         this_ptr_conv.is_owned = false;
31464         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
31465         return ret_conv;
31466 }
31467
31468 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint64_t this_ptr, int32_t val) {
31469         LDKUnsignedNodeAnnouncement this_ptr_conv;
31470         this_ptr_conv.inner = untag_ptr(this_ptr);
31471         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31473         this_ptr_conv.is_owned = false;
31474         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
31475 }
31476
31477 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint64_t this_ptr) {
31478         LDKUnsignedNodeAnnouncement this_ptr_conv;
31479         this_ptr_conv.inner = untag_ptr(this_ptr);
31480         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31482         this_ptr_conv.is_owned = false;
31483         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31484         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
31485         return ret_arr;
31486 }
31487
31488 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint64_t this_ptr, int8_tArray val) {
31489         LDKUnsignedNodeAnnouncement this_ptr_conv;
31490         this_ptr_conv.inner = untag_ptr(this_ptr);
31491         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31493         this_ptr_conv.is_owned = false;
31494         LDKPublicKey val_ref;
31495         CHECK(val->arr_len == 33);
31496         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31497         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
31498 }
31499
31500 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint64_t this_ptr) {
31501         LDKUnsignedNodeAnnouncement this_ptr_conv;
31502         this_ptr_conv.inner = untag_ptr(this_ptr);
31503         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31505         this_ptr_conv.is_owned = false;
31506         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
31507         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
31508         return ret_arr;
31509 }
31510
31511 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint64_t this_ptr, int8_tArray val) {
31512         LDKUnsignedNodeAnnouncement this_ptr_conv;
31513         this_ptr_conv.inner = untag_ptr(this_ptr);
31514         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31516         this_ptr_conv.is_owned = false;
31517         LDKThreeBytes val_ref;
31518         CHECK(val->arr_len == 3);
31519         memcpy(val_ref.data, val->elems, 3); FREE(val);
31520         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
31521 }
31522
31523 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint64_t this_ptr) {
31524         LDKUnsignedNodeAnnouncement this_ptr_conv;
31525         this_ptr_conv.inner = untag_ptr(this_ptr);
31526         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31528         this_ptr_conv.is_owned = false;
31529         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31530         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
31531         return ret_arr;
31532 }
31533
31534 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint64_t this_ptr, int8_tArray val) {
31535         LDKUnsignedNodeAnnouncement this_ptr_conv;
31536         this_ptr_conv.inner = untag_ptr(this_ptr);
31537         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31539         this_ptr_conv.is_owned = false;
31540         LDKThirtyTwoBytes val_ref;
31541         CHECK(val->arr_len == 32);
31542         memcpy(val_ref.data, val->elems, 32); FREE(val);
31543         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
31544 }
31545
31546 uint64_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_addresses"))) TS_UnsignedNodeAnnouncement_get_addresses(uint64_t this_ptr) {
31547         LDKUnsignedNodeAnnouncement this_ptr_conv;
31548         this_ptr_conv.inner = untag_ptr(this_ptr);
31549         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31551         this_ptr_conv.is_owned = false;
31552         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
31553         uint64_tArray ret_arr = NULL;
31554         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
31555         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
31556         for (size_t m = 0; m < ret_var.datalen; m++) {
31557                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31558                 *ret_conv_12_copy = ret_var.data[m];
31559                 uint64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
31560                 ret_arr_ptr[m] = ret_conv_12_ref;
31561         }
31562         
31563         FREE(ret_var.data);
31564         return ret_arr;
31565 }
31566
31567 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint64_t this_ptr, uint64_tArray val) {
31568         LDKUnsignedNodeAnnouncement this_ptr_conv;
31569         this_ptr_conv.inner = untag_ptr(this_ptr);
31570         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31572         this_ptr_conv.is_owned = false;
31573         LDKCVec_NetAddressZ val_constr;
31574         val_constr.datalen = val->arr_len;
31575         if (val_constr.datalen > 0)
31576                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
31577         else
31578                 val_constr.data = NULL;
31579         uint64_t* val_vals = val->elems;
31580         for (size_t m = 0; m < val_constr.datalen; m++) {
31581                 uint64_t val_conv_12 = val_vals[m];
31582                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
31583                 CHECK_ACCESS(val_conv_12_ptr);
31584                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
31585                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
31586                 val_constr.data[m] = val_conv_12_conv;
31587         }
31588         FREE(val);
31589         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
31590 }
31591
31592 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
31593         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
31594         uint64_t ret_ref = 0;
31595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31596         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31597         return ret_ref;
31598 }
31599 int64_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint64_t arg) {
31600         LDKUnsignedNodeAnnouncement arg_conv;
31601         arg_conv.inner = untag_ptr(arg);
31602         arg_conv.is_owned = ptr_is_owned(arg);
31603         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31604         arg_conv.is_owned = false;
31605         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
31606         return ret_conv;
31607 }
31608
31609 uint64_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint64_t orig) {
31610         LDKUnsignedNodeAnnouncement orig_conv;
31611         orig_conv.inner = untag_ptr(orig);
31612         orig_conv.is_owned = ptr_is_owned(orig);
31613         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31614         orig_conv.is_owned = false;
31615         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
31616         uint64_t ret_ref = 0;
31617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31618         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31619         return ret_ref;
31620 }
31621
31622 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint64_t this_obj) {
31623         LDKNodeAnnouncement this_obj_conv;
31624         this_obj_conv.inner = untag_ptr(this_obj);
31625         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31627         NodeAnnouncement_free(this_obj_conv);
31628 }
31629
31630 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint64_t this_ptr) {
31631         LDKNodeAnnouncement this_ptr_conv;
31632         this_ptr_conv.inner = untag_ptr(this_ptr);
31633         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31635         this_ptr_conv.is_owned = false;
31636         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31637         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
31638         return ret_arr;
31639 }
31640
31641 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint64_t this_ptr, int8_tArray val) {
31642         LDKNodeAnnouncement this_ptr_conv;
31643         this_ptr_conv.inner = untag_ptr(this_ptr);
31644         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31646         this_ptr_conv.is_owned = false;
31647         LDKSignature val_ref;
31648         CHECK(val->arr_len == 64);
31649         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31650         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
31651 }
31652
31653 uint64_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint64_t this_ptr) {
31654         LDKNodeAnnouncement this_ptr_conv;
31655         this_ptr_conv.inner = untag_ptr(this_ptr);
31656         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31658         this_ptr_conv.is_owned = false;
31659         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
31660         uint64_t ret_ref = 0;
31661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31662         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31663         return ret_ref;
31664 }
31665
31666 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint64_t this_ptr, uint64_t val) {
31667         LDKNodeAnnouncement this_ptr_conv;
31668         this_ptr_conv.inner = untag_ptr(this_ptr);
31669         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31671         this_ptr_conv.is_owned = false;
31672         LDKUnsignedNodeAnnouncement val_conv;
31673         val_conv.inner = untag_ptr(val);
31674         val_conv.is_owned = ptr_is_owned(val);
31675         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31676         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
31677         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
31678 }
31679
31680 uint64_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint64_t contents_arg) {
31681         LDKSignature signature_arg_ref;
31682         CHECK(signature_arg->arr_len == 64);
31683         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
31684         LDKUnsignedNodeAnnouncement contents_arg_conv;
31685         contents_arg_conv.inner = untag_ptr(contents_arg);
31686         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
31687         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
31688         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
31689         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
31690         uint64_t ret_ref = 0;
31691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31692         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31693         return ret_ref;
31694 }
31695
31696 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
31697         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
31698         uint64_t ret_ref = 0;
31699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31700         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31701         return ret_ref;
31702 }
31703 int64_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint64_t arg) {
31704         LDKNodeAnnouncement arg_conv;
31705         arg_conv.inner = untag_ptr(arg);
31706         arg_conv.is_owned = ptr_is_owned(arg);
31707         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31708         arg_conv.is_owned = false;
31709         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
31710         return ret_conv;
31711 }
31712
31713 uint64_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint64_t orig) {
31714         LDKNodeAnnouncement orig_conv;
31715         orig_conv.inner = untag_ptr(orig);
31716         orig_conv.is_owned = ptr_is_owned(orig);
31717         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31718         orig_conv.is_owned = false;
31719         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
31720         uint64_t ret_ref = 0;
31721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31722         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31723         return ret_ref;
31724 }
31725
31726 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint64_t this_obj) {
31727         LDKUnsignedChannelAnnouncement this_obj_conv;
31728         this_obj_conv.inner = untag_ptr(this_obj);
31729         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31731         UnsignedChannelAnnouncement_free(this_obj_conv);
31732 }
31733
31734 uint64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint64_t this_ptr) {
31735         LDKUnsignedChannelAnnouncement this_ptr_conv;
31736         this_ptr_conv.inner = untag_ptr(this_ptr);
31737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31739         this_ptr_conv.is_owned = false;
31740         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
31741         uint64_t ret_ref = 0;
31742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31743         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31744         return ret_ref;
31745 }
31746
31747 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint64_t this_ptr, uint64_t val) {
31748         LDKUnsignedChannelAnnouncement this_ptr_conv;
31749         this_ptr_conv.inner = untag_ptr(this_ptr);
31750         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31752         this_ptr_conv.is_owned = false;
31753         LDKChannelFeatures val_conv;
31754         val_conv.inner = untag_ptr(val);
31755         val_conv.is_owned = ptr_is_owned(val);
31756         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31757         val_conv = ChannelFeatures_clone(&val_conv);
31758         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
31759 }
31760
31761 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint64_t this_ptr) {
31762         LDKUnsignedChannelAnnouncement this_ptr_conv;
31763         this_ptr_conv.inner = untag_ptr(this_ptr);
31764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31766         this_ptr_conv.is_owned = false;
31767         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31768         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
31769         return ret_arr;
31770 }
31771
31772 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint64_t this_ptr, int8_tArray val) {
31773         LDKUnsignedChannelAnnouncement this_ptr_conv;
31774         this_ptr_conv.inner = untag_ptr(this_ptr);
31775         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31777         this_ptr_conv.is_owned = false;
31778         LDKThirtyTwoBytes val_ref;
31779         CHECK(val->arr_len == 32);
31780         memcpy(val_ref.data, val->elems, 32); FREE(val);
31781         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
31782 }
31783
31784 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint64_t this_ptr) {
31785         LDKUnsignedChannelAnnouncement this_ptr_conv;
31786         this_ptr_conv.inner = untag_ptr(this_ptr);
31787         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31789         this_ptr_conv.is_owned = false;
31790         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
31791         return ret_conv;
31792 }
31793
31794 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint64_t this_ptr, int64_t val) {
31795         LDKUnsignedChannelAnnouncement this_ptr_conv;
31796         this_ptr_conv.inner = untag_ptr(this_ptr);
31797         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31799         this_ptr_conv.is_owned = false;
31800         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
31801 }
31802
31803 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint64_t this_ptr) {
31804         LDKUnsignedChannelAnnouncement this_ptr_conv;
31805         this_ptr_conv.inner = untag_ptr(this_ptr);
31806         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31808         this_ptr_conv.is_owned = false;
31809         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31810         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
31811         return ret_arr;
31812 }
31813
31814 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint64_t this_ptr, int8_tArray val) {
31815         LDKUnsignedChannelAnnouncement this_ptr_conv;
31816         this_ptr_conv.inner = untag_ptr(this_ptr);
31817         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31819         this_ptr_conv.is_owned = false;
31820         LDKPublicKey val_ref;
31821         CHECK(val->arr_len == 33);
31822         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31823         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
31824 }
31825
31826 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint64_t this_ptr) {
31827         LDKUnsignedChannelAnnouncement this_ptr_conv;
31828         this_ptr_conv.inner = untag_ptr(this_ptr);
31829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31831         this_ptr_conv.is_owned = false;
31832         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31833         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
31834         return ret_arr;
31835 }
31836
31837 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint64_t this_ptr, int8_tArray val) {
31838         LDKUnsignedChannelAnnouncement this_ptr_conv;
31839         this_ptr_conv.inner = untag_ptr(this_ptr);
31840         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31842         this_ptr_conv.is_owned = false;
31843         LDKPublicKey val_ref;
31844         CHECK(val->arr_len == 33);
31845         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31846         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
31847 }
31848
31849 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint64_t this_ptr) {
31850         LDKUnsignedChannelAnnouncement this_ptr_conv;
31851         this_ptr_conv.inner = untag_ptr(this_ptr);
31852         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31854         this_ptr_conv.is_owned = false;
31855         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31856         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
31857         return ret_arr;
31858 }
31859
31860 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint64_t this_ptr, int8_tArray val) {
31861         LDKUnsignedChannelAnnouncement this_ptr_conv;
31862         this_ptr_conv.inner = untag_ptr(this_ptr);
31863         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31865         this_ptr_conv.is_owned = false;
31866         LDKPublicKey val_ref;
31867         CHECK(val->arr_len == 33);
31868         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31869         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
31870 }
31871
31872 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint64_t this_ptr) {
31873         LDKUnsignedChannelAnnouncement this_ptr_conv;
31874         this_ptr_conv.inner = untag_ptr(this_ptr);
31875         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31877         this_ptr_conv.is_owned = false;
31878         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31879         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
31880         return ret_arr;
31881 }
31882
31883 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint64_t this_ptr, int8_tArray val) {
31884         LDKUnsignedChannelAnnouncement this_ptr_conv;
31885         this_ptr_conv.inner = untag_ptr(this_ptr);
31886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31888         this_ptr_conv.is_owned = false;
31889         LDKPublicKey val_ref;
31890         CHECK(val->arr_len == 33);
31891         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31892         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
31893 }
31894
31895 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
31896         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
31897         uint64_t ret_ref = 0;
31898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31899         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31900         return ret_ref;
31901 }
31902 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint64_t arg) {
31903         LDKUnsignedChannelAnnouncement arg_conv;
31904         arg_conv.inner = untag_ptr(arg);
31905         arg_conv.is_owned = ptr_is_owned(arg);
31906         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31907         arg_conv.is_owned = false;
31908         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
31909         return ret_conv;
31910 }
31911
31912 uint64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint64_t orig) {
31913         LDKUnsignedChannelAnnouncement orig_conv;
31914         orig_conv.inner = untag_ptr(orig);
31915         orig_conv.is_owned = ptr_is_owned(orig);
31916         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31917         orig_conv.is_owned = false;
31918         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
31919         uint64_t ret_ref = 0;
31920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31921         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31922         return ret_ref;
31923 }
31924
31925 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint64_t this_obj) {
31926         LDKChannelAnnouncement this_obj_conv;
31927         this_obj_conv.inner = untag_ptr(this_obj);
31928         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31930         ChannelAnnouncement_free(this_obj_conv);
31931 }
31932
31933 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint64_t this_ptr) {
31934         LDKChannelAnnouncement this_ptr_conv;
31935         this_ptr_conv.inner = untag_ptr(this_ptr);
31936         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31938         this_ptr_conv.is_owned = false;
31939         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31940         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
31941         return ret_arr;
31942 }
31943
31944 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint64_t this_ptr, int8_tArray val) {
31945         LDKChannelAnnouncement this_ptr_conv;
31946         this_ptr_conv.inner = untag_ptr(this_ptr);
31947         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31949         this_ptr_conv.is_owned = false;
31950         LDKSignature val_ref;
31951         CHECK(val->arr_len == 64);
31952         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31953         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
31954 }
31955
31956 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint64_t this_ptr) {
31957         LDKChannelAnnouncement this_ptr_conv;
31958         this_ptr_conv.inner = untag_ptr(this_ptr);
31959         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31961         this_ptr_conv.is_owned = false;
31962         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31963         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
31964         return ret_arr;
31965 }
31966
31967 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint64_t this_ptr, int8_tArray val) {
31968         LDKChannelAnnouncement this_ptr_conv;
31969         this_ptr_conv.inner = untag_ptr(this_ptr);
31970         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31972         this_ptr_conv.is_owned = false;
31973         LDKSignature val_ref;
31974         CHECK(val->arr_len == 64);
31975         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31976         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
31977 }
31978
31979 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint64_t this_ptr) {
31980         LDKChannelAnnouncement this_ptr_conv;
31981         this_ptr_conv.inner = untag_ptr(this_ptr);
31982         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31984         this_ptr_conv.is_owned = false;
31985         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31986         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
31987         return ret_arr;
31988 }
31989
31990 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint64_t this_ptr, int8_tArray val) {
31991         LDKChannelAnnouncement this_ptr_conv;
31992         this_ptr_conv.inner = untag_ptr(this_ptr);
31993         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31995         this_ptr_conv.is_owned = false;
31996         LDKSignature val_ref;
31997         CHECK(val->arr_len == 64);
31998         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31999         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
32000 }
32001
32002 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint64_t this_ptr) {
32003         LDKChannelAnnouncement this_ptr_conv;
32004         this_ptr_conv.inner = untag_ptr(this_ptr);
32005         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32007         this_ptr_conv.is_owned = false;
32008         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32009         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
32010         return ret_arr;
32011 }
32012
32013 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint64_t this_ptr, int8_tArray val) {
32014         LDKChannelAnnouncement this_ptr_conv;
32015         this_ptr_conv.inner = untag_ptr(this_ptr);
32016         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32018         this_ptr_conv.is_owned = false;
32019         LDKSignature val_ref;
32020         CHECK(val->arr_len == 64);
32021         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32022         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
32023 }
32024
32025 uint64_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint64_t this_ptr) {
32026         LDKChannelAnnouncement this_ptr_conv;
32027         this_ptr_conv.inner = untag_ptr(this_ptr);
32028         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32030         this_ptr_conv.is_owned = false;
32031         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
32032         uint64_t ret_ref = 0;
32033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32034         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32035         return ret_ref;
32036 }
32037
32038 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint64_t this_ptr, uint64_t val) {
32039         LDKChannelAnnouncement this_ptr_conv;
32040         this_ptr_conv.inner = untag_ptr(this_ptr);
32041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32043         this_ptr_conv.is_owned = false;
32044         LDKUnsignedChannelAnnouncement val_conv;
32045         val_conv.inner = untag_ptr(val);
32046         val_conv.is_owned = ptr_is_owned(val);
32047         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32048         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
32049         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
32050 }
32051
32052 uint64_t  __attribute__((export_name("TS_ChannelAnnouncement_new"))) 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, uint64_t contents_arg) {
32053         LDKSignature node_signature_1_arg_ref;
32054         CHECK(node_signature_1_arg->arr_len == 64);
32055         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
32056         LDKSignature node_signature_2_arg_ref;
32057         CHECK(node_signature_2_arg->arr_len == 64);
32058         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
32059         LDKSignature bitcoin_signature_1_arg_ref;
32060         CHECK(bitcoin_signature_1_arg->arr_len == 64);
32061         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
32062         LDKSignature bitcoin_signature_2_arg_ref;
32063         CHECK(bitcoin_signature_2_arg->arr_len == 64);
32064         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
32065         LDKUnsignedChannelAnnouncement contents_arg_conv;
32066         contents_arg_conv.inner = untag_ptr(contents_arg);
32067         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
32068         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
32069         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
32070         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);
32071         uint64_t ret_ref = 0;
32072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32073         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32074         return ret_ref;
32075 }
32076
32077 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
32078         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
32079         uint64_t ret_ref = 0;
32080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32081         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32082         return ret_ref;
32083 }
32084 int64_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint64_t arg) {
32085         LDKChannelAnnouncement arg_conv;
32086         arg_conv.inner = untag_ptr(arg);
32087         arg_conv.is_owned = ptr_is_owned(arg);
32088         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32089         arg_conv.is_owned = false;
32090         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
32091         return ret_conv;
32092 }
32093
32094 uint64_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint64_t orig) {
32095         LDKChannelAnnouncement orig_conv;
32096         orig_conv.inner = untag_ptr(orig);
32097         orig_conv.is_owned = ptr_is_owned(orig);
32098         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32099         orig_conv.is_owned = false;
32100         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
32101         uint64_t ret_ref = 0;
32102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32103         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32104         return ret_ref;
32105 }
32106
32107 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint64_t this_obj) {
32108         LDKUnsignedChannelUpdate this_obj_conv;
32109         this_obj_conv.inner = untag_ptr(this_obj);
32110         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32112         UnsignedChannelUpdate_free(this_obj_conv);
32113 }
32114
32115 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint64_t this_ptr) {
32116         LDKUnsignedChannelUpdate this_ptr_conv;
32117         this_ptr_conv.inner = untag_ptr(this_ptr);
32118         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32120         this_ptr_conv.is_owned = false;
32121         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32122         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
32123         return ret_arr;
32124 }
32125
32126 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint64_t this_ptr, int8_tArray val) {
32127         LDKUnsignedChannelUpdate this_ptr_conv;
32128         this_ptr_conv.inner = untag_ptr(this_ptr);
32129         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32131         this_ptr_conv.is_owned = false;
32132         LDKThirtyTwoBytes val_ref;
32133         CHECK(val->arr_len == 32);
32134         memcpy(val_ref.data, val->elems, 32); FREE(val);
32135         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
32136 }
32137
32138 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint64_t this_ptr) {
32139         LDKUnsignedChannelUpdate this_ptr_conv;
32140         this_ptr_conv.inner = untag_ptr(this_ptr);
32141         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32143         this_ptr_conv.is_owned = false;
32144         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
32145         return ret_conv;
32146 }
32147
32148 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint64_t this_ptr, int64_t val) {
32149         LDKUnsignedChannelUpdate this_ptr_conv;
32150         this_ptr_conv.inner = untag_ptr(this_ptr);
32151         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32153         this_ptr_conv.is_owned = false;
32154         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
32155 }
32156
32157 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint64_t this_ptr) {
32158         LDKUnsignedChannelUpdate this_ptr_conv;
32159         this_ptr_conv.inner = untag_ptr(this_ptr);
32160         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32162         this_ptr_conv.is_owned = false;
32163         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
32164         return ret_conv;
32165 }
32166
32167 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint64_t this_ptr, int32_t val) {
32168         LDKUnsignedChannelUpdate this_ptr_conv;
32169         this_ptr_conv.inner = untag_ptr(this_ptr);
32170         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32172         this_ptr_conv.is_owned = false;
32173         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
32174 }
32175
32176 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint64_t this_ptr) {
32177         LDKUnsignedChannelUpdate this_ptr_conv;
32178         this_ptr_conv.inner = untag_ptr(this_ptr);
32179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32181         this_ptr_conv.is_owned = false;
32182         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
32183         return ret_conv;
32184 }
32185
32186 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint64_t this_ptr, int8_t val) {
32187         LDKUnsignedChannelUpdate this_ptr_conv;
32188         this_ptr_conv.inner = untag_ptr(this_ptr);
32189         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32191         this_ptr_conv.is_owned = false;
32192         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
32193 }
32194
32195 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint64_t this_ptr) {
32196         LDKUnsignedChannelUpdate this_ptr_conv;
32197         this_ptr_conv.inner = untag_ptr(this_ptr);
32198         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32200         this_ptr_conv.is_owned = false;
32201         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
32202         return ret_conv;
32203 }
32204
32205 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint64_t this_ptr, int16_t val) {
32206         LDKUnsignedChannelUpdate this_ptr_conv;
32207         this_ptr_conv.inner = untag_ptr(this_ptr);
32208         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32210         this_ptr_conv.is_owned = false;
32211         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
32212 }
32213
32214 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint64_t this_ptr) {
32215         LDKUnsignedChannelUpdate this_ptr_conv;
32216         this_ptr_conv.inner = untag_ptr(this_ptr);
32217         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32219         this_ptr_conv.is_owned = false;
32220         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
32221         return ret_conv;
32222 }
32223
32224 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint64_t this_ptr, int64_t val) {
32225         LDKUnsignedChannelUpdate this_ptr_conv;
32226         this_ptr_conv.inner = untag_ptr(this_ptr);
32227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32229         this_ptr_conv.is_owned = false;
32230         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
32231 }
32232
32233 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_maximum_msat"))) TS_UnsignedChannelUpdate_get_htlc_maximum_msat(uint64_t this_ptr) {
32234         LDKUnsignedChannelUpdate this_ptr_conv;
32235         this_ptr_conv.inner = untag_ptr(this_ptr);
32236         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32238         this_ptr_conv.is_owned = false;
32239         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
32240         return ret_conv;
32241 }
32242
32243 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_maximum_msat"))) TS_UnsignedChannelUpdate_set_htlc_maximum_msat(uint64_t this_ptr, int64_t val) {
32244         LDKUnsignedChannelUpdate this_ptr_conv;
32245         this_ptr_conv.inner = untag_ptr(this_ptr);
32246         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32248         this_ptr_conv.is_owned = false;
32249         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
32250 }
32251
32252 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint64_t this_ptr) {
32253         LDKUnsignedChannelUpdate this_ptr_conv;
32254         this_ptr_conv.inner = untag_ptr(this_ptr);
32255         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32257         this_ptr_conv.is_owned = false;
32258         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
32259         return ret_conv;
32260 }
32261
32262 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint64_t this_ptr, int32_t val) {
32263         LDKUnsignedChannelUpdate this_ptr_conv;
32264         this_ptr_conv.inner = untag_ptr(this_ptr);
32265         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32267         this_ptr_conv.is_owned = false;
32268         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
32269 }
32270
32271 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint64_t this_ptr) {
32272         LDKUnsignedChannelUpdate this_ptr_conv;
32273         this_ptr_conv.inner = untag_ptr(this_ptr);
32274         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32276         this_ptr_conv.is_owned = false;
32277         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
32278         return ret_conv;
32279 }
32280
32281 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint64_t this_ptr, int32_t val) {
32282         LDKUnsignedChannelUpdate this_ptr_conv;
32283         this_ptr_conv.inner = untag_ptr(this_ptr);
32284         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32286         this_ptr_conv.is_owned = false;
32287         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
32288 }
32289
32290 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_excess_data"))) TS_UnsignedChannelUpdate_get_excess_data(uint64_t this_ptr) {
32291         LDKUnsignedChannelUpdate this_ptr_conv;
32292         this_ptr_conv.inner = untag_ptr(this_ptr);
32293         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32295         this_ptr_conv.is_owned = false;
32296         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
32297         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32298         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32299         CVec_u8Z_free(ret_var);
32300         return ret_arr;
32301 }
32302
32303 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_excess_data"))) TS_UnsignedChannelUpdate_set_excess_data(uint64_t this_ptr, int8_tArray val) {
32304         LDKUnsignedChannelUpdate this_ptr_conv;
32305         this_ptr_conv.inner = untag_ptr(this_ptr);
32306         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32308         this_ptr_conv.is_owned = false;
32309         LDKCVec_u8Z val_ref;
32310         val_ref.datalen = val->arr_len;
32311         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
32312         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
32313         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
32314 }
32315
32316 uint64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_new"))) TS_UnsignedChannelUpdate_new(int8_tArray chain_hash_arg, int64_t short_channel_id_arg, int32_t timestamp_arg, int8_t flags_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int8_tArray excess_data_arg) {
32317         LDKThirtyTwoBytes chain_hash_arg_ref;
32318         CHECK(chain_hash_arg->arr_len == 32);
32319         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32320         LDKCVec_u8Z excess_data_arg_ref;
32321         excess_data_arg_ref.datalen = excess_data_arg->arr_len;
32322         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
32323         memcpy(excess_data_arg_ref.data, excess_data_arg->elems, excess_data_arg_ref.datalen); FREE(excess_data_arg);
32324         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_new(chain_hash_arg_ref, short_channel_id_arg, timestamp_arg, flags_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fee_base_msat_arg, fee_proportional_millionths_arg, excess_data_arg_ref);
32325         uint64_t ret_ref = 0;
32326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32327         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32328         return ret_ref;
32329 }
32330
32331 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
32332         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
32333         uint64_t ret_ref = 0;
32334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32335         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32336         return ret_ref;
32337 }
32338 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint64_t arg) {
32339         LDKUnsignedChannelUpdate arg_conv;
32340         arg_conv.inner = untag_ptr(arg);
32341         arg_conv.is_owned = ptr_is_owned(arg);
32342         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32343         arg_conv.is_owned = false;
32344         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
32345         return ret_conv;
32346 }
32347
32348 uint64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint64_t orig) {
32349         LDKUnsignedChannelUpdate orig_conv;
32350         orig_conv.inner = untag_ptr(orig);
32351         orig_conv.is_owned = ptr_is_owned(orig);
32352         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32353         orig_conv.is_owned = false;
32354         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
32355         uint64_t ret_ref = 0;
32356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32357         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32358         return ret_ref;
32359 }
32360
32361 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint64_t this_obj) {
32362         LDKChannelUpdate this_obj_conv;
32363         this_obj_conv.inner = untag_ptr(this_obj);
32364         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32366         ChannelUpdate_free(this_obj_conv);
32367 }
32368
32369 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint64_t this_ptr) {
32370         LDKChannelUpdate this_ptr_conv;
32371         this_ptr_conv.inner = untag_ptr(this_ptr);
32372         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32374         this_ptr_conv.is_owned = false;
32375         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32376         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
32377         return ret_arr;
32378 }
32379
32380 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint64_t this_ptr, int8_tArray val) {
32381         LDKChannelUpdate this_ptr_conv;
32382         this_ptr_conv.inner = untag_ptr(this_ptr);
32383         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32385         this_ptr_conv.is_owned = false;
32386         LDKSignature val_ref;
32387         CHECK(val->arr_len == 64);
32388         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32389         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
32390 }
32391
32392 uint64_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint64_t this_ptr) {
32393         LDKChannelUpdate this_ptr_conv;
32394         this_ptr_conv.inner = untag_ptr(this_ptr);
32395         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32397         this_ptr_conv.is_owned = false;
32398         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
32399         uint64_t ret_ref = 0;
32400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32401         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32402         return ret_ref;
32403 }
32404
32405 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint64_t this_ptr, uint64_t val) {
32406         LDKChannelUpdate this_ptr_conv;
32407         this_ptr_conv.inner = untag_ptr(this_ptr);
32408         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32410         this_ptr_conv.is_owned = false;
32411         LDKUnsignedChannelUpdate val_conv;
32412         val_conv.inner = untag_ptr(val);
32413         val_conv.is_owned = ptr_is_owned(val);
32414         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32415         val_conv = UnsignedChannelUpdate_clone(&val_conv);
32416         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
32417 }
32418
32419 uint64_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint64_t contents_arg) {
32420         LDKSignature signature_arg_ref;
32421         CHECK(signature_arg->arr_len == 64);
32422         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
32423         LDKUnsignedChannelUpdate contents_arg_conv;
32424         contents_arg_conv.inner = untag_ptr(contents_arg);
32425         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
32426         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
32427         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
32428         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
32429         uint64_t ret_ref = 0;
32430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32431         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32432         return ret_ref;
32433 }
32434
32435 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
32436         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
32437         uint64_t ret_ref = 0;
32438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32439         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32440         return ret_ref;
32441 }
32442 int64_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint64_t arg) {
32443         LDKChannelUpdate arg_conv;
32444         arg_conv.inner = untag_ptr(arg);
32445         arg_conv.is_owned = ptr_is_owned(arg);
32446         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32447         arg_conv.is_owned = false;
32448         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
32449         return ret_conv;
32450 }
32451
32452 uint64_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint64_t orig) {
32453         LDKChannelUpdate orig_conv;
32454         orig_conv.inner = untag_ptr(orig);
32455         orig_conv.is_owned = ptr_is_owned(orig);
32456         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32457         orig_conv.is_owned = false;
32458         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
32459         uint64_t ret_ref = 0;
32460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32461         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32462         return ret_ref;
32463 }
32464
32465 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint64_t this_obj) {
32466         LDKQueryChannelRange this_obj_conv;
32467         this_obj_conv.inner = untag_ptr(this_obj);
32468         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32470         QueryChannelRange_free(this_obj_conv);
32471 }
32472
32473 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint64_t this_ptr) {
32474         LDKQueryChannelRange this_ptr_conv;
32475         this_ptr_conv.inner = untag_ptr(this_ptr);
32476         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32478         this_ptr_conv.is_owned = false;
32479         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32480         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
32481         return ret_arr;
32482 }
32483
32484 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint64_t this_ptr, int8_tArray val) {
32485         LDKQueryChannelRange this_ptr_conv;
32486         this_ptr_conv.inner = untag_ptr(this_ptr);
32487         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32489         this_ptr_conv.is_owned = false;
32490         LDKThirtyTwoBytes val_ref;
32491         CHECK(val->arr_len == 32);
32492         memcpy(val_ref.data, val->elems, 32); FREE(val);
32493         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
32494 }
32495
32496 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint64_t this_ptr) {
32497         LDKQueryChannelRange this_ptr_conv;
32498         this_ptr_conv.inner = untag_ptr(this_ptr);
32499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32501         this_ptr_conv.is_owned = false;
32502         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
32503         return ret_conv;
32504 }
32505
32506 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint64_t this_ptr, int32_t val) {
32507         LDKQueryChannelRange this_ptr_conv;
32508         this_ptr_conv.inner = untag_ptr(this_ptr);
32509         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32511         this_ptr_conv.is_owned = false;
32512         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
32513 }
32514
32515 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint64_t this_ptr) {
32516         LDKQueryChannelRange this_ptr_conv;
32517         this_ptr_conv.inner = untag_ptr(this_ptr);
32518         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32520         this_ptr_conv.is_owned = false;
32521         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
32522         return ret_conv;
32523 }
32524
32525 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint64_t this_ptr, int32_t val) {
32526         LDKQueryChannelRange this_ptr_conv;
32527         this_ptr_conv.inner = untag_ptr(this_ptr);
32528         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32530         this_ptr_conv.is_owned = false;
32531         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
32532 }
32533
32534 uint64_t  __attribute__((export_name("TS_QueryChannelRange_new"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
32535         LDKThirtyTwoBytes chain_hash_arg_ref;
32536         CHECK(chain_hash_arg->arr_len == 32);
32537         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32538         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
32539         uint64_t ret_ref = 0;
32540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32541         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32542         return ret_ref;
32543 }
32544
32545 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
32546         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
32547         uint64_t ret_ref = 0;
32548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32549         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32550         return ret_ref;
32551 }
32552 int64_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint64_t arg) {
32553         LDKQueryChannelRange arg_conv;
32554         arg_conv.inner = untag_ptr(arg);
32555         arg_conv.is_owned = ptr_is_owned(arg);
32556         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32557         arg_conv.is_owned = false;
32558         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
32559         return ret_conv;
32560 }
32561
32562 uint64_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint64_t orig) {
32563         LDKQueryChannelRange orig_conv;
32564         orig_conv.inner = untag_ptr(orig);
32565         orig_conv.is_owned = ptr_is_owned(orig);
32566         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32567         orig_conv.is_owned = false;
32568         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
32569         uint64_t ret_ref = 0;
32570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32571         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32572         return ret_ref;
32573 }
32574
32575 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint64_t this_obj) {
32576         LDKReplyChannelRange this_obj_conv;
32577         this_obj_conv.inner = untag_ptr(this_obj);
32578         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32580         ReplyChannelRange_free(this_obj_conv);
32581 }
32582
32583 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint64_t this_ptr) {
32584         LDKReplyChannelRange this_ptr_conv;
32585         this_ptr_conv.inner = untag_ptr(this_ptr);
32586         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32588         this_ptr_conv.is_owned = false;
32589         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32590         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
32591         return ret_arr;
32592 }
32593
32594 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint64_t this_ptr, int8_tArray val) {
32595         LDKReplyChannelRange this_ptr_conv;
32596         this_ptr_conv.inner = untag_ptr(this_ptr);
32597         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32599         this_ptr_conv.is_owned = false;
32600         LDKThirtyTwoBytes val_ref;
32601         CHECK(val->arr_len == 32);
32602         memcpy(val_ref.data, val->elems, 32); FREE(val);
32603         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
32604 }
32605
32606 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint64_t this_ptr) {
32607         LDKReplyChannelRange this_ptr_conv;
32608         this_ptr_conv.inner = untag_ptr(this_ptr);
32609         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32611         this_ptr_conv.is_owned = false;
32612         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
32613         return ret_conv;
32614 }
32615
32616 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint64_t this_ptr, int32_t val) {
32617         LDKReplyChannelRange this_ptr_conv;
32618         this_ptr_conv.inner = untag_ptr(this_ptr);
32619         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32621         this_ptr_conv.is_owned = false;
32622         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
32623 }
32624
32625 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint64_t this_ptr) {
32626         LDKReplyChannelRange this_ptr_conv;
32627         this_ptr_conv.inner = untag_ptr(this_ptr);
32628         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32630         this_ptr_conv.is_owned = false;
32631         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
32632         return ret_conv;
32633 }
32634
32635 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint64_t this_ptr, int32_t val) {
32636         LDKReplyChannelRange this_ptr_conv;
32637         this_ptr_conv.inner = untag_ptr(this_ptr);
32638         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32640         this_ptr_conv.is_owned = false;
32641         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
32642 }
32643
32644 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint64_t this_ptr) {
32645         LDKReplyChannelRange this_ptr_conv;
32646         this_ptr_conv.inner = untag_ptr(this_ptr);
32647         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32649         this_ptr_conv.is_owned = false;
32650         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
32651         return ret_conv;
32652 }
32653
32654 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint64_t this_ptr, jboolean val) {
32655         LDKReplyChannelRange this_ptr_conv;
32656         this_ptr_conv.inner = untag_ptr(this_ptr);
32657         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32659         this_ptr_conv.is_owned = false;
32660         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
32661 }
32662
32663 int64_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_short_channel_ids"))) TS_ReplyChannelRange_get_short_channel_ids(uint64_t this_ptr) {
32664         LDKReplyChannelRange this_ptr_conv;
32665         this_ptr_conv.inner = untag_ptr(this_ptr);
32666         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32668         this_ptr_conv.is_owned = false;
32669         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
32670         int64_tArray ret_arr = NULL;
32671         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
32672         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
32673         for (size_t i = 0; i < ret_var.datalen; i++) {
32674                 int64_t ret_conv_8_conv = ret_var.data[i];
32675                 ret_arr_ptr[i] = ret_conv_8_conv;
32676         }
32677         
32678         FREE(ret_var.data);
32679         return ret_arr;
32680 }
32681
32682 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint64_t this_ptr, int64_tArray val) {
32683         LDKReplyChannelRange this_ptr_conv;
32684         this_ptr_conv.inner = untag_ptr(this_ptr);
32685         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32687         this_ptr_conv.is_owned = false;
32688         LDKCVec_u64Z val_constr;
32689         val_constr.datalen = val->arr_len;
32690         if (val_constr.datalen > 0)
32691                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32692         else
32693                 val_constr.data = NULL;
32694         int64_t* val_vals = val->elems;
32695         for (size_t i = 0; i < val_constr.datalen; i++) {
32696                 int64_t val_conv_8 = val_vals[i];
32697                 val_constr.data[i] = val_conv_8;
32698         }
32699         FREE(val);
32700         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
32701 }
32702
32703 uint64_t  __attribute__((export_name("TS_ReplyChannelRange_new"))) 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) {
32704         LDKThirtyTwoBytes chain_hash_arg_ref;
32705         CHECK(chain_hash_arg->arr_len == 32);
32706         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32707         LDKCVec_u64Z short_channel_ids_arg_constr;
32708         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
32709         if (short_channel_ids_arg_constr.datalen > 0)
32710                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32711         else
32712                 short_channel_ids_arg_constr.data = NULL;
32713         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
32714         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
32715                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
32716                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
32717         }
32718         FREE(short_channel_ids_arg);
32719         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
32720         uint64_t ret_ref = 0;
32721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32722         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32723         return ret_ref;
32724 }
32725
32726 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
32727         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
32728         uint64_t ret_ref = 0;
32729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32730         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32731         return ret_ref;
32732 }
32733 int64_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint64_t arg) {
32734         LDKReplyChannelRange arg_conv;
32735         arg_conv.inner = untag_ptr(arg);
32736         arg_conv.is_owned = ptr_is_owned(arg);
32737         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32738         arg_conv.is_owned = false;
32739         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
32740         return ret_conv;
32741 }
32742
32743 uint64_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint64_t orig) {
32744         LDKReplyChannelRange orig_conv;
32745         orig_conv.inner = untag_ptr(orig);
32746         orig_conv.is_owned = ptr_is_owned(orig);
32747         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32748         orig_conv.is_owned = false;
32749         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
32750         uint64_t ret_ref = 0;
32751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32752         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32753         return ret_ref;
32754 }
32755
32756 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint64_t this_obj) {
32757         LDKQueryShortChannelIds this_obj_conv;
32758         this_obj_conv.inner = untag_ptr(this_obj);
32759         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32761         QueryShortChannelIds_free(this_obj_conv);
32762 }
32763
32764 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint64_t this_ptr) {
32765         LDKQueryShortChannelIds this_ptr_conv;
32766         this_ptr_conv.inner = untag_ptr(this_ptr);
32767         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32769         this_ptr_conv.is_owned = false;
32770         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32771         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
32772         return ret_arr;
32773 }
32774
32775 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint64_t this_ptr, int8_tArray val) {
32776         LDKQueryShortChannelIds this_ptr_conv;
32777         this_ptr_conv.inner = untag_ptr(this_ptr);
32778         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32780         this_ptr_conv.is_owned = false;
32781         LDKThirtyTwoBytes val_ref;
32782         CHECK(val->arr_len == 32);
32783         memcpy(val_ref.data, val->elems, 32); FREE(val);
32784         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
32785 }
32786
32787 int64_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_short_channel_ids"))) TS_QueryShortChannelIds_get_short_channel_ids(uint64_t this_ptr) {
32788         LDKQueryShortChannelIds this_ptr_conv;
32789         this_ptr_conv.inner = untag_ptr(this_ptr);
32790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32792         this_ptr_conv.is_owned = false;
32793         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
32794         int64_tArray ret_arr = NULL;
32795         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
32796         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
32797         for (size_t i = 0; i < ret_var.datalen; i++) {
32798                 int64_t ret_conv_8_conv = ret_var.data[i];
32799                 ret_arr_ptr[i] = ret_conv_8_conv;
32800         }
32801         
32802         FREE(ret_var.data);
32803         return ret_arr;
32804 }
32805
32806 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint64_t this_ptr, int64_tArray val) {
32807         LDKQueryShortChannelIds this_ptr_conv;
32808         this_ptr_conv.inner = untag_ptr(this_ptr);
32809         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32811         this_ptr_conv.is_owned = false;
32812         LDKCVec_u64Z val_constr;
32813         val_constr.datalen = val->arr_len;
32814         if (val_constr.datalen > 0)
32815                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32816         else
32817                 val_constr.data = NULL;
32818         int64_t* val_vals = val->elems;
32819         for (size_t i = 0; i < val_constr.datalen; i++) {
32820                 int64_t val_conv_8 = val_vals[i];
32821                 val_constr.data[i] = val_conv_8;
32822         }
32823         FREE(val);
32824         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
32825 }
32826
32827 uint64_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
32828         LDKThirtyTwoBytes chain_hash_arg_ref;
32829         CHECK(chain_hash_arg->arr_len == 32);
32830         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32831         LDKCVec_u64Z short_channel_ids_arg_constr;
32832         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
32833         if (short_channel_ids_arg_constr.datalen > 0)
32834                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32835         else
32836                 short_channel_ids_arg_constr.data = NULL;
32837         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
32838         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
32839                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
32840                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
32841         }
32842         FREE(short_channel_ids_arg);
32843         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
32844         uint64_t ret_ref = 0;
32845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32846         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32847         return ret_ref;
32848 }
32849
32850 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
32851         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
32852         uint64_t ret_ref = 0;
32853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32854         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32855         return ret_ref;
32856 }
32857 int64_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint64_t arg) {
32858         LDKQueryShortChannelIds arg_conv;
32859         arg_conv.inner = untag_ptr(arg);
32860         arg_conv.is_owned = ptr_is_owned(arg);
32861         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32862         arg_conv.is_owned = false;
32863         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
32864         return ret_conv;
32865 }
32866
32867 uint64_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint64_t orig) {
32868         LDKQueryShortChannelIds orig_conv;
32869         orig_conv.inner = untag_ptr(orig);
32870         orig_conv.is_owned = ptr_is_owned(orig);
32871         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32872         orig_conv.is_owned = false;
32873         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
32874         uint64_t ret_ref = 0;
32875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32876         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32877         return ret_ref;
32878 }
32879
32880 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint64_t this_obj) {
32881         LDKReplyShortChannelIdsEnd this_obj_conv;
32882         this_obj_conv.inner = untag_ptr(this_obj);
32883         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32885         ReplyShortChannelIdsEnd_free(this_obj_conv);
32886 }
32887
32888 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint64_t this_ptr) {
32889         LDKReplyShortChannelIdsEnd this_ptr_conv;
32890         this_ptr_conv.inner = untag_ptr(this_ptr);
32891         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32893         this_ptr_conv.is_owned = false;
32894         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32895         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
32896         return ret_arr;
32897 }
32898
32899 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint64_t this_ptr, int8_tArray val) {
32900         LDKReplyShortChannelIdsEnd this_ptr_conv;
32901         this_ptr_conv.inner = untag_ptr(this_ptr);
32902         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32904         this_ptr_conv.is_owned = false;
32905         LDKThirtyTwoBytes val_ref;
32906         CHECK(val->arr_len == 32);
32907         memcpy(val_ref.data, val->elems, 32); FREE(val);
32908         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
32909 }
32910
32911 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint64_t this_ptr) {
32912         LDKReplyShortChannelIdsEnd this_ptr_conv;
32913         this_ptr_conv.inner = untag_ptr(this_ptr);
32914         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32916         this_ptr_conv.is_owned = false;
32917         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
32918         return ret_conv;
32919 }
32920
32921 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint64_t this_ptr, jboolean val) {
32922         LDKReplyShortChannelIdsEnd this_ptr_conv;
32923         this_ptr_conv.inner = untag_ptr(this_ptr);
32924         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32926         this_ptr_conv.is_owned = false;
32927         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
32928 }
32929
32930 uint64_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
32931         LDKThirtyTwoBytes chain_hash_arg_ref;
32932         CHECK(chain_hash_arg->arr_len == 32);
32933         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32934         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
32935         uint64_t ret_ref = 0;
32936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32937         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32938         return ret_ref;
32939 }
32940
32941 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
32942         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
32943         uint64_t ret_ref = 0;
32944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32945         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32946         return ret_ref;
32947 }
32948 int64_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint64_t arg) {
32949         LDKReplyShortChannelIdsEnd arg_conv;
32950         arg_conv.inner = untag_ptr(arg);
32951         arg_conv.is_owned = ptr_is_owned(arg);
32952         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32953         arg_conv.is_owned = false;
32954         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
32955         return ret_conv;
32956 }
32957
32958 uint64_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint64_t orig) {
32959         LDKReplyShortChannelIdsEnd orig_conv;
32960         orig_conv.inner = untag_ptr(orig);
32961         orig_conv.is_owned = ptr_is_owned(orig);
32962         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32963         orig_conv.is_owned = false;
32964         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
32965         uint64_t ret_ref = 0;
32966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32967         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32968         return ret_ref;
32969 }
32970
32971 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint64_t this_obj) {
32972         LDKGossipTimestampFilter this_obj_conv;
32973         this_obj_conv.inner = untag_ptr(this_obj);
32974         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32976         GossipTimestampFilter_free(this_obj_conv);
32977 }
32978
32979 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint64_t this_ptr) {
32980         LDKGossipTimestampFilter this_ptr_conv;
32981         this_ptr_conv.inner = untag_ptr(this_ptr);
32982         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32984         this_ptr_conv.is_owned = false;
32985         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32986         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
32987         return ret_arr;
32988 }
32989
32990 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint64_t this_ptr, int8_tArray val) {
32991         LDKGossipTimestampFilter this_ptr_conv;
32992         this_ptr_conv.inner = untag_ptr(this_ptr);
32993         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32995         this_ptr_conv.is_owned = false;
32996         LDKThirtyTwoBytes val_ref;
32997         CHECK(val->arr_len == 32);
32998         memcpy(val_ref.data, val->elems, 32); FREE(val);
32999         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
33000 }
33001
33002 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint64_t this_ptr) {
33003         LDKGossipTimestampFilter this_ptr_conv;
33004         this_ptr_conv.inner = untag_ptr(this_ptr);
33005         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33007         this_ptr_conv.is_owned = false;
33008         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
33009         return ret_conv;
33010 }
33011
33012 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint64_t this_ptr, int32_t val) {
33013         LDKGossipTimestampFilter this_ptr_conv;
33014         this_ptr_conv.inner = untag_ptr(this_ptr);
33015         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33017         this_ptr_conv.is_owned = false;
33018         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
33019 }
33020
33021 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint64_t this_ptr) {
33022         LDKGossipTimestampFilter this_ptr_conv;
33023         this_ptr_conv.inner = untag_ptr(this_ptr);
33024         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33026         this_ptr_conv.is_owned = false;
33027         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
33028         return ret_conv;
33029 }
33030
33031 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint64_t this_ptr, int32_t val) {
33032         LDKGossipTimestampFilter this_ptr_conv;
33033         this_ptr_conv.inner = untag_ptr(this_ptr);
33034         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33036         this_ptr_conv.is_owned = false;
33037         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
33038 }
33039
33040 uint64_t  __attribute__((export_name("TS_GossipTimestampFilter_new"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
33041         LDKThirtyTwoBytes chain_hash_arg_ref;
33042         CHECK(chain_hash_arg->arr_len == 32);
33043         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
33044         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
33045         uint64_t ret_ref = 0;
33046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33047         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33048         return ret_ref;
33049 }
33050
33051 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
33052         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
33053         uint64_t ret_ref = 0;
33054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33055         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33056         return ret_ref;
33057 }
33058 int64_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint64_t arg) {
33059         LDKGossipTimestampFilter arg_conv;
33060         arg_conv.inner = untag_ptr(arg);
33061         arg_conv.is_owned = ptr_is_owned(arg);
33062         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33063         arg_conv.is_owned = false;
33064         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
33065         return ret_conv;
33066 }
33067
33068 uint64_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint64_t orig) {
33069         LDKGossipTimestampFilter orig_conv;
33070         orig_conv.inner = untag_ptr(orig);
33071         orig_conv.is_owned = ptr_is_owned(orig);
33072         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33073         orig_conv.is_owned = false;
33074         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
33075         uint64_t ret_ref = 0;
33076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33078         return ret_ref;
33079 }
33080
33081 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint64_t this_ptr) {
33082         if (!ptr_is_owned(this_ptr)) return;
33083         void* this_ptr_ptr = untag_ptr(this_ptr);
33084         CHECK_ACCESS(this_ptr_ptr);
33085         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
33086         FREE(untag_ptr(this_ptr));
33087         ErrorAction_free(this_ptr_conv);
33088 }
33089
33090 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
33091         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33092         *ret_copy = ErrorAction_clone(arg);
33093         uint64_t ret_ref = tag_ptr(ret_copy, true);
33094         return ret_ref;
33095 }
33096 int64_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint64_t arg) {
33097         LDKErrorAction* arg_conv = (LDKErrorAction*)untag_ptr(arg);
33098         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
33099         return ret_conv;
33100 }
33101
33102 uint64_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint64_t orig) {
33103         LDKErrorAction* orig_conv = (LDKErrorAction*)untag_ptr(orig);
33104         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33105         *ret_copy = ErrorAction_clone(orig_conv);
33106         uint64_t ret_ref = tag_ptr(ret_copy, true);
33107         return ret_ref;
33108 }
33109
33110 uint64_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint64_t msg) {
33111         LDKErrorMessage msg_conv;
33112         msg_conv.inner = untag_ptr(msg);
33113         msg_conv.is_owned = ptr_is_owned(msg);
33114         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33115         msg_conv = ErrorMessage_clone(&msg_conv);
33116         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33117         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
33118         uint64_t ret_ref = tag_ptr(ret_copy, true);
33119         return ret_ref;
33120 }
33121
33122 uint64_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
33123         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33124         *ret_copy = ErrorAction_ignore_error();
33125         uint64_t ret_ref = tag_ptr(ret_copy, true);
33126         return ret_ref;
33127 }
33128
33129 uint64_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
33130         LDKLevel a_conv = LDKLevel_from_js(a);
33131         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33132         *ret_copy = ErrorAction_ignore_and_log(a_conv);
33133         uint64_t ret_ref = tag_ptr(ret_copy, true);
33134         return ret_ref;
33135 }
33136
33137 uint64_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
33138         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33139         *ret_copy = ErrorAction_ignore_duplicate_gossip();
33140         uint64_t ret_ref = tag_ptr(ret_copy, true);
33141         return ret_ref;
33142 }
33143
33144 uint64_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint64_t msg) {
33145         LDKErrorMessage msg_conv;
33146         msg_conv.inner = untag_ptr(msg);
33147         msg_conv.is_owned = ptr_is_owned(msg);
33148         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33149         msg_conv = ErrorMessage_clone(&msg_conv);
33150         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33151         *ret_copy = ErrorAction_send_error_message(msg_conv);
33152         uint64_t ret_ref = tag_ptr(ret_copy, true);
33153         return ret_ref;
33154 }
33155
33156 uint64_t  __attribute__((export_name("TS_ErrorAction_send_warning_message"))) TS_ErrorAction_send_warning_message(uint64_t msg, uint32_t log_level) {
33157         LDKWarningMessage msg_conv;
33158         msg_conv.inner = untag_ptr(msg);
33159         msg_conv.is_owned = ptr_is_owned(msg);
33160         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33161         msg_conv = WarningMessage_clone(&msg_conv);
33162         LDKLevel log_level_conv = LDKLevel_from_js(log_level);
33163         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33164         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
33165         uint64_t ret_ref = tag_ptr(ret_copy, true);
33166         return ret_ref;
33167 }
33168
33169 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint64_t this_obj) {
33170         LDKLightningError this_obj_conv;
33171         this_obj_conv.inner = untag_ptr(this_obj);
33172         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33174         LightningError_free(this_obj_conv);
33175 }
33176
33177 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint64_t this_ptr) {
33178         LDKLightningError this_ptr_conv;
33179         this_ptr_conv.inner = untag_ptr(this_ptr);
33180         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33182         this_ptr_conv.is_owned = false;
33183         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
33184         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
33185         Str_free(ret_str);
33186         return ret_conv;
33187 }
33188
33189 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint64_t this_ptr, jstring val) {
33190         LDKLightningError this_ptr_conv;
33191         this_ptr_conv.inner = untag_ptr(this_ptr);
33192         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33194         this_ptr_conv.is_owned = false;
33195         LDKStr val_conv = str_ref_to_owned_c(val);
33196         LightningError_set_err(&this_ptr_conv, val_conv);
33197 }
33198
33199 uint64_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint64_t this_ptr) {
33200         LDKLightningError this_ptr_conv;
33201         this_ptr_conv.inner = untag_ptr(this_ptr);
33202         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33204         this_ptr_conv.is_owned = false;
33205         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33206         *ret_copy = LightningError_get_action(&this_ptr_conv);
33207         uint64_t ret_ref = tag_ptr(ret_copy, true);
33208         return ret_ref;
33209 }
33210
33211 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint64_t this_ptr, uint64_t val) {
33212         LDKLightningError this_ptr_conv;
33213         this_ptr_conv.inner = untag_ptr(this_ptr);
33214         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33216         this_ptr_conv.is_owned = false;
33217         void* val_ptr = untag_ptr(val);
33218         CHECK_ACCESS(val_ptr);
33219         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
33220         val_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(val));
33221         LightningError_set_action(&this_ptr_conv, val_conv);
33222 }
33223
33224 uint64_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint64_t action_arg) {
33225         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
33226         void* action_arg_ptr = untag_ptr(action_arg);
33227         CHECK_ACCESS(action_arg_ptr);
33228         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
33229         action_arg_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action_arg));
33230         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
33231         uint64_t ret_ref = 0;
33232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33233         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33234         return ret_ref;
33235 }
33236
33237 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
33238         LDKLightningError ret_var = LightningError_clone(arg);
33239         uint64_t ret_ref = 0;
33240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33241         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33242         return ret_ref;
33243 }
33244 int64_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint64_t arg) {
33245         LDKLightningError arg_conv;
33246         arg_conv.inner = untag_ptr(arg);
33247         arg_conv.is_owned = ptr_is_owned(arg);
33248         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33249         arg_conv.is_owned = false;
33250         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
33251         return ret_conv;
33252 }
33253
33254 uint64_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint64_t orig) {
33255         LDKLightningError orig_conv;
33256         orig_conv.inner = untag_ptr(orig);
33257         orig_conv.is_owned = ptr_is_owned(orig);
33258         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33259         orig_conv.is_owned = false;
33260         LDKLightningError ret_var = LightningError_clone(&orig_conv);
33261         uint64_t ret_ref = 0;
33262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33263         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33264         return ret_ref;
33265 }
33266
33267 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint64_t this_obj) {
33268         LDKCommitmentUpdate this_obj_conv;
33269         this_obj_conv.inner = untag_ptr(this_obj);
33270         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33272         CommitmentUpdate_free(this_obj_conv);
33273 }
33274
33275 uint64_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint64_t this_ptr) {
33276         LDKCommitmentUpdate this_ptr_conv;
33277         this_ptr_conv.inner = untag_ptr(this_ptr);
33278         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33280         this_ptr_conv.is_owned = false;
33281         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
33282         uint64_tArray ret_arr = NULL;
33283         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
33284         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
33285         for (size_t p = 0; p < ret_var.datalen; p++) {
33286                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
33287                 uint64_t ret_conv_15_ref = 0;
33288                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
33289                 ret_conv_15_ref = tag_ptr(ret_conv_15_var.inner, ret_conv_15_var.is_owned);
33290                 ret_arr_ptr[p] = ret_conv_15_ref;
33291         }
33292         
33293         FREE(ret_var.data);
33294         return ret_arr;
33295 }
33296
33297 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint64_t this_ptr, uint64_tArray val) {
33298         LDKCommitmentUpdate this_ptr_conv;
33299         this_ptr_conv.inner = untag_ptr(this_ptr);
33300         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33302         this_ptr_conv.is_owned = false;
33303         LDKCVec_UpdateAddHTLCZ val_constr;
33304         val_constr.datalen = val->arr_len;
33305         if (val_constr.datalen > 0)
33306                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
33307         else
33308                 val_constr.data = NULL;
33309         uint64_t* val_vals = val->elems;
33310         for (size_t p = 0; p < val_constr.datalen; p++) {
33311                 uint64_t val_conv_15 = val_vals[p];
33312                 LDKUpdateAddHTLC val_conv_15_conv;
33313                 val_conv_15_conv.inner = untag_ptr(val_conv_15);
33314                 val_conv_15_conv.is_owned = ptr_is_owned(val_conv_15);
33315                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
33316                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
33317                 val_constr.data[p] = val_conv_15_conv;
33318         }
33319         FREE(val);
33320         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
33321 }
33322
33323 uint64_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint64_t this_ptr) {
33324         LDKCommitmentUpdate this_ptr_conv;
33325         this_ptr_conv.inner = untag_ptr(this_ptr);
33326         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33328         this_ptr_conv.is_owned = false;
33329         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
33330         uint64_tArray ret_arr = NULL;
33331         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
33332         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
33333         for (size_t t = 0; t < ret_var.datalen; t++) {
33334                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
33335                 uint64_t ret_conv_19_ref = 0;
33336                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
33337                 ret_conv_19_ref = tag_ptr(ret_conv_19_var.inner, ret_conv_19_var.is_owned);
33338                 ret_arr_ptr[t] = ret_conv_19_ref;
33339         }
33340         
33341         FREE(ret_var.data);
33342         return ret_arr;
33343 }
33344
33345 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint64_t this_ptr, uint64_tArray val) {
33346         LDKCommitmentUpdate this_ptr_conv;
33347         this_ptr_conv.inner = untag_ptr(this_ptr);
33348         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33350         this_ptr_conv.is_owned = false;
33351         LDKCVec_UpdateFulfillHTLCZ val_constr;
33352         val_constr.datalen = val->arr_len;
33353         if (val_constr.datalen > 0)
33354                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
33355         else
33356                 val_constr.data = NULL;
33357         uint64_t* val_vals = val->elems;
33358         for (size_t t = 0; t < val_constr.datalen; t++) {
33359                 uint64_t val_conv_19 = val_vals[t];
33360                 LDKUpdateFulfillHTLC val_conv_19_conv;
33361                 val_conv_19_conv.inner = untag_ptr(val_conv_19);
33362                 val_conv_19_conv.is_owned = ptr_is_owned(val_conv_19);
33363                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
33364                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
33365                 val_constr.data[t] = val_conv_19_conv;
33366         }
33367         FREE(val);
33368         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
33369 }
33370
33371 uint64_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint64_t this_ptr) {
33372         LDKCommitmentUpdate this_ptr_conv;
33373         this_ptr_conv.inner = untag_ptr(this_ptr);
33374         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33376         this_ptr_conv.is_owned = false;
33377         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
33378         uint64_tArray ret_arr = NULL;
33379         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
33380         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
33381         for (size_t q = 0; q < ret_var.datalen; q++) {
33382                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
33383                 uint64_t ret_conv_16_ref = 0;
33384                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33385                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33386                 ret_arr_ptr[q] = ret_conv_16_ref;
33387         }
33388         
33389         FREE(ret_var.data);
33390         return ret_arr;
33391 }
33392
33393 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint64_t this_ptr, uint64_tArray val) {
33394         LDKCommitmentUpdate this_ptr_conv;
33395         this_ptr_conv.inner = untag_ptr(this_ptr);
33396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33398         this_ptr_conv.is_owned = false;
33399         LDKCVec_UpdateFailHTLCZ val_constr;
33400         val_constr.datalen = val->arr_len;
33401         if (val_constr.datalen > 0)
33402                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
33403         else
33404                 val_constr.data = NULL;
33405         uint64_t* val_vals = val->elems;
33406         for (size_t q = 0; q < val_constr.datalen; q++) {
33407                 uint64_t val_conv_16 = val_vals[q];
33408                 LDKUpdateFailHTLC val_conv_16_conv;
33409                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
33410                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
33411                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
33412                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
33413                 val_constr.data[q] = val_conv_16_conv;
33414         }
33415         FREE(val);
33416         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
33417 }
33418
33419 uint64_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint64_t this_ptr) {
33420         LDKCommitmentUpdate this_ptr_conv;
33421         this_ptr_conv.inner = untag_ptr(this_ptr);
33422         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33424         this_ptr_conv.is_owned = false;
33425         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
33426         uint64_tArray ret_arr = NULL;
33427         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
33428         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
33429         for (size_t z = 0; z < ret_var.datalen; z++) {
33430                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
33431                 uint64_t ret_conv_25_ref = 0;
33432                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
33433                 ret_conv_25_ref = tag_ptr(ret_conv_25_var.inner, ret_conv_25_var.is_owned);
33434                 ret_arr_ptr[z] = ret_conv_25_ref;
33435         }
33436         
33437         FREE(ret_var.data);
33438         return ret_arr;
33439 }
33440
33441 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint64_t this_ptr, uint64_tArray val) {
33442         LDKCommitmentUpdate this_ptr_conv;
33443         this_ptr_conv.inner = untag_ptr(this_ptr);
33444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33446         this_ptr_conv.is_owned = false;
33447         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
33448         val_constr.datalen = val->arr_len;
33449         if (val_constr.datalen > 0)
33450                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
33451         else
33452                 val_constr.data = NULL;
33453         uint64_t* val_vals = val->elems;
33454         for (size_t z = 0; z < val_constr.datalen; z++) {
33455                 uint64_t val_conv_25 = val_vals[z];
33456                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
33457                 val_conv_25_conv.inner = untag_ptr(val_conv_25);
33458                 val_conv_25_conv.is_owned = ptr_is_owned(val_conv_25);
33459                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
33460                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
33461                 val_constr.data[z] = val_conv_25_conv;
33462         }
33463         FREE(val);
33464         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
33465 }
33466
33467 uint64_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint64_t this_ptr) {
33468         LDKCommitmentUpdate this_ptr_conv;
33469         this_ptr_conv.inner = untag_ptr(this_ptr);
33470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33472         this_ptr_conv.is_owned = false;
33473         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
33474         uint64_t ret_ref = 0;
33475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33476         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33477         return ret_ref;
33478 }
33479
33480 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint64_t this_ptr, uint64_t val) {
33481         LDKCommitmentUpdate this_ptr_conv;
33482         this_ptr_conv.inner = untag_ptr(this_ptr);
33483         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33485         this_ptr_conv.is_owned = false;
33486         LDKUpdateFee val_conv;
33487         val_conv.inner = untag_ptr(val);
33488         val_conv.is_owned = ptr_is_owned(val);
33489         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33490         val_conv = UpdateFee_clone(&val_conv);
33491         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
33492 }
33493
33494 uint64_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint64_t this_ptr) {
33495         LDKCommitmentUpdate this_ptr_conv;
33496         this_ptr_conv.inner = untag_ptr(this_ptr);
33497         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33499         this_ptr_conv.is_owned = false;
33500         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
33501         uint64_t ret_ref = 0;
33502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33503         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33504         return ret_ref;
33505 }
33506
33507 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint64_t this_ptr, uint64_t val) {
33508         LDKCommitmentUpdate this_ptr_conv;
33509         this_ptr_conv.inner = untag_ptr(this_ptr);
33510         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33512         this_ptr_conv.is_owned = false;
33513         LDKCommitmentSigned val_conv;
33514         val_conv.inner = untag_ptr(val);
33515         val_conv.is_owned = ptr_is_owned(val);
33516         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33517         val_conv = CommitmentSigned_clone(&val_conv);
33518         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
33519 }
33520
33521 uint64_t  __attribute__((export_name("TS_CommitmentUpdate_new"))) TS_CommitmentUpdate_new(uint64_tArray update_add_htlcs_arg, uint64_tArray update_fulfill_htlcs_arg, uint64_tArray update_fail_htlcs_arg, uint64_tArray update_fail_malformed_htlcs_arg, uint64_t update_fee_arg, uint64_t commitment_signed_arg) {
33522         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
33523         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
33524         if (update_add_htlcs_arg_constr.datalen > 0)
33525                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
33526         else
33527                 update_add_htlcs_arg_constr.data = NULL;
33528         uint64_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems;
33529         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
33530                 uint64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
33531                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
33532                 update_add_htlcs_arg_conv_15_conv.inner = untag_ptr(update_add_htlcs_arg_conv_15);
33533                 update_add_htlcs_arg_conv_15_conv.is_owned = ptr_is_owned(update_add_htlcs_arg_conv_15);
33534                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
33535                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
33536                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
33537         }
33538         FREE(update_add_htlcs_arg);
33539         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
33540         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
33541         if (update_fulfill_htlcs_arg_constr.datalen > 0)
33542                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
33543         else
33544                 update_fulfill_htlcs_arg_constr.data = NULL;
33545         uint64_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems;
33546         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
33547                 uint64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
33548                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
33549                 update_fulfill_htlcs_arg_conv_19_conv.inner = untag_ptr(update_fulfill_htlcs_arg_conv_19);
33550                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = ptr_is_owned(update_fulfill_htlcs_arg_conv_19);
33551                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
33552                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
33553                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
33554         }
33555         FREE(update_fulfill_htlcs_arg);
33556         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
33557         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
33558         if (update_fail_htlcs_arg_constr.datalen > 0)
33559                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
33560         else
33561                 update_fail_htlcs_arg_constr.data = NULL;
33562         uint64_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems;
33563         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
33564                 uint64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
33565                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
33566                 update_fail_htlcs_arg_conv_16_conv.inner = untag_ptr(update_fail_htlcs_arg_conv_16);
33567                 update_fail_htlcs_arg_conv_16_conv.is_owned = ptr_is_owned(update_fail_htlcs_arg_conv_16);
33568                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
33569                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
33570                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
33571         }
33572         FREE(update_fail_htlcs_arg);
33573         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
33574         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
33575         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
33576                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
33577         else
33578                 update_fail_malformed_htlcs_arg_constr.data = NULL;
33579         uint64_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems;
33580         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
33581                 uint64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
33582                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
33583                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = untag_ptr(update_fail_malformed_htlcs_arg_conv_25);
33584                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = ptr_is_owned(update_fail_malformed_htlcs_arg_conv_25);
33585                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
33586                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
33587                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
33588         }
33589         FREE(update_fail_malformed_htlcs_arg);
33590         LDKUpdateFee update_fee_arg_conv;
33591         update_fee_arg_conv.inner = untag_ptr(update_fee_arg);
33592         update_fee_arg_conv.is_owned = ptr_is_owned(update_fee_arg);
33593         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
33594         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
33595         LDKCommitmentSigned commitment_signed_arg_conv;
33596         commitment_signed_arg_conv.inner = untag_ptr(commitment_signed_arg);
33597         commitment_signed_arg_conv.is_owned = ptr_is_owned(commitment_signed_arg);
33598         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
33599         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
33600         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);
33601         uint64_t ret_ref = 0;
33602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33603         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33604         return ret_ref;
33605 }
33606
33607 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
33608         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
33609         uint64_t ret_ref = 0;
33610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33611         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33612         return ret_ref;
33613 }
33614 int64_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint64_t arg) {
33615         LDKCommitmentUpdate arg_conv;
33616         arg_conv.inner = untag_ptr(arg);
33617         arg_conv.is_owned = ptr_is_owned(arg);
33618         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33619         arg_conv.is_owned = false;
33620         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
33621         return ret_conv;
33622 }
33623
33624 uint64_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint64_t orig) {
33625         LDKCommitmentUpdate orig_conv;
33626         orig_conv.inner = untag_ptr(orig);
33627         orig_conv.is_owned = ptr_is_owned(orig);
33628         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33629         orig_conv.is_owned = false;
33630         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
33631         uint64_t ret_ref = 0;
33632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33633         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33634         return ret_ref;
33635 }
33636
33637 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint64_t this_ptr) {
33638         if (!ptr_is_owned(this_ptr)) return;
33639         void* this_ptr_ptr = untag_ptr(this_ptr);
33640         CHECK_ACCESS(this_ptr_ptr);
33641         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
33642         FREE(untag_ptr(this_ptr));
33643         ChannelMessageHandler_free(this_ptr_conv);
33644 }
33645
33646 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint64_t this_ptr) {
33647         if (!ptr_is_owned(this_ptr)) return;
33648         void* this_ptr_ptr = untag_ptr(this_ptr);
33649         CHECK_ACCESS(this_ptr_ptr);
33650         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
33651         FREE(untag_ptr(this_ptr));
33652         RoutingMessageHandler_free(this_ptr_conv);
33653 }
33654
33655 void  __attribute__((export_name("TS_OnionMessageHandler_free"))) TS_OnionMessageHandler_free(uint64_t this_ptr) {
33656         if (!ptr_is_owned(this_ptr)) return;
33657         void* this_ptr_ptr = untag_ptr(this_ptr);
33658         CHECK_ACCESS(this_ptr_ptr);
33659         LDKOnionMessageHandler this_ptr_conv = *(LDKOnionMessageHandler*)(this_ptr_ptr);
33660         FREE(untag_ptr(this_ptr));
33661         OnionMessageHandler_free(this_ptr_conv);
33662 }
33663
33664 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint64_t obj) {
33665         LDKAcceptChannel obj_conv;
33666         obj_conv.inner = untag_ptr(obj);
33667         obj_conv.is_owned = ptr_is_owned(obj);
33668         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33669         obj_conv.is_owned = false;
33670         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
33671         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33672         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33673         CVec_u8Z_free(ret_var);
33674         return ret_arr;
33675 }
33676
33677 uint64_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
33678         LDKu8slice ser_ref;
33679         ser_ref.datalen = ser->arr_len;
33680         ser_ref.data = ser->elems;
33681         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
33682         *ret_conv = AcceptChannel_read(ser_ref);
33683         FREE(ser);
33684         return tag_ptr(ret_conv, true);
33685 }
33686
33687 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint64_t obj) {
33688         LDKAnnouncementSignatures obj_conv;
33689         obj_conv.inner = untag_ptr(obj);
33690         obj_conv.is_owned = ptr_is_owned(obj);
33691         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33692         obj_conv.is_owned = false;
33693         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
33694         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33695         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33696         CVec_u8Z_free(ret_var);
33697         return ret_arr;
33698 }
33699
33700 uint64_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
33701         LDKu8slice ser_ref;
33702         ser_ref.datalen = ser->arr_len;
33703         ser_ref.data = ser->elems;
33704         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
33705         *ret_conv = AnnouncementSignatures_read(ser_ref);
33706         FREE(ser);
33707         return tag_ptr(ret_conv, true);
33708 }
33709
33710 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint64_t obj) {
33711         LDKChannelReestablish obj_conv;
33712         obj_conv.inner = untag_ptr(obj);
33713         obj_conv.is_owned = ptr_is_owned(obj);
33714         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33715         obj_conv.is_owned = false;
33716         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
33717         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33718         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33719         CVec_u8Z_free(ret_var);
33720         return ret_arr;
33721 }
33722
33723 uint64_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
33724         LDKu8slice ser_ref;
33725         ser_ref.datalen = ser->arr_len;
33726         ser_ref.data = ser->elems;
33727         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
33728         *ret_conv = ChannelReestablish_read(ser_ref);
33729         FREE(ser);
33730         return tag_ptr(ret_conv, true);
33731 }
33732
33733 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint64_t obj) {
33734         LDKClosingSigned obj_conv;
33735         obj_conv.inner = untag_ptr(obj);
33736         obj_conv.is_owned = ptr_is_owned(obj);
33737         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33738         obj_conv.is_owned = false;
33739         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
33740         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33741         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33742         CVec_u8Z_free(ret_var);
33743         return ret_arr;
33744 }
33745
33746 uint64_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
33747         LDKu8slice ser_ref;
33748         ser_ref.datalen = ser->arr_len;
33749         ser_ref.data = ser->elems;
33750         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
33751         *ret_conv = ClosingSigned_read(ser_ref);
33752         FREE(ser);
33753         return tag_ptr(ret_conv, true);
33754 }
33755
33756 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint64_t obj) {
33757         LDKClosingSignedFeeRange obj_conv;
33758         obj_conv.inner = untag_ptr(obj);
33759         obj_conv.is_owned = ptr_is_owned(obj);
33760         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33761         obj_conv.is_owned = false;
33762         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
33763         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33764         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33765         CVec_u8Z_free(ret_var);
33766         return ret_arr;
33767 }
33768
33769 uint64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
33770         LDKu8slice ser_ref;
33771         ser_ref.datalen = ser->arr_len;
33772         ser_ref.data = ser->elems;
33773         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
33774         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
33775         FREE(ser);
33776         return tag_ptr(ret_conv, true);
33777 }
33778
33779 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint64_t obj) {
33780         LDKCommitmentSigned obj_conv;
33781         obj_conv.inner = untag_ptr(obj);
33782         obj_conv.is_owned = ptr_is_owned(obj);
33783         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33784         obj_conv.is_owned = false;
33785         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
33786         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33787         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33788         CVec_u8Z_free(ret_var);
33789         return ret_arr;
33790 }
33791
33792 uint64_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
33793         LDKu8slice ser_ref;
33794         ser_ref.datalen = ser->arr_len;
33795         ser_ref.data = ser->elems;
33796         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
33797         *ret_conv = CommitmentSigned_read(ser_ref);
33798         FREE(ser);
33799         return tag_ptr(ret_conv, true);
33800 }
33801
33802 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint64_t obj) {
33803         LDKFundingCreated obj_conv;
33804         obj_conv.inner = untag_ptr(obj);
33805         obj_conv.is_owned = ptr_is_owned(obj);
33806         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33807         obj_conv.is_owned = false;
33808         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
33809         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33810         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33811         CVec_u8Z_free(ret_var);
33812         return ret_arr;
33813 }
33814
33815 uint64_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
33816         LDKu8slice ser_ref;
33817         ser_ref.datalen = ser->arr_len;
33818         ser_ref.data = ser->elems;
33819         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
33820         *ret_conv = FundingCreated_read(ser_ref);
33821         FREE(ser);
33822         return tag_ptr(ret_conv, true);
33823 }
33824
33825 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint64_t obj) {
33826         LDKFundingSigned obj_conv;
33827         obj_conv.inner = untag_ptr(obj);
33828         obj_conv.is_owned = ptr_is_owned(obj);
33829         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33830         obj_conv.is_owned = false;
33831         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
33832         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33833         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33834         CVec_u8Z_free(ret_var);
33835         return ret_arr;
33836 }
33837
33838 uint64_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
33839         LDKu8slice ser_ref;
33840         ser_ref.datalen = ser->arr_len;
33841         ser_ref.data = ser->elems;
33842         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
33843         *ret_conv = FundingSigned_read(ser_ref);
33844         FREE(ser);
33845         return tag_ptr(ret_conv, true);
33846 }
33847
33848 int8_tArray  __attribute__((export_name("TS_ChannelReady_write"))) TS_ChannelReady_write(uint64_t obj) {
33849         LDKChannelReady obj_conv;
33850         obj_conv.inner = untag_ptr(obj);
33851         obj_conv.is_owned = ptr_is_owned(obj);
33852         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33853         obj_conv.is_owned = false;
33854         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
33855         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33856         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33857         CVec_u8Z_free(ret_var);
33858         return ret_arr;
33859 }
33860
33861 uint64_t  __attribute__((export_name("TS_ChannelReady_read"))) TS_ChannelReady_read(int8_tArray ser) {
33862         LDKu8slice ser_ref;
33863         ser_ref.datalen = ser->arr_len;
33864         ser_ref.data = ser->elems;
33865         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
33866         *ret_conv = ChannelReady_read(ser_ref);
33867         FREE(ser);
33868         return tag_ptr(ret_conv, true);
33869 }
33870
33871 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint64_t obj) {
33872         LDKInit obj_conv;
33873         obj_conv.inner = untag_ptr(obj);
33874         obj_conv.is_owned = ptr_is_owned(obj);
33875         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33876         obj_conv.is_owned = false;
33877         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
33878         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33879         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33880         CVec_u8Z_free(ret_var);
33881         return ret_arr;
33882 }
33883
33884 uint64_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
33885         LDKu8slice ser_ref;
33886         ser_ref.datalen = ser->arr_len;
33887         ser_ref.data = ser->elems;
33888         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
33889         *ret_conv = Init_read(ser_ref);
33890         FREE(ser);
33891         return tag_ptr(ret_conv, true);
33892 }
33893
33894 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint64_t obj) {
33895         LDKOpenChannel obj_conv;
33896         obj_conv.inner = untag_ptr(obj);
33897         obj_conv.is_owned = ptr_is_owned(obj);
33898         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33899         obj_conv.is_owned = false;
33900         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
33901         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33902         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33903         CVec_u8Z_free(ret_var);
33904         return ret_arr;
33905 }
33906
33907 uint64_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
33908         LDKu8slice ser_ref;
33909         ser_ref.datalen = ser->arr_len;
33910         ser_ref.data = ser->elems;
33911         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
33912         *ret_conv = OpenChannel_read(ser_ref);
33913         FREE(ser);
33914         return tag_ptr(ret_conv, true);
33915 }
33916
33917 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint64_t obj) {
33918         LDKRevokeAndACK obj_conv;
33919         obj_conv.inner = untag_ptr(obj);
33920         obj_conv.is_owned = ptr_is_owned(obj);
33921         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33922         obj_conv.is_owned = false;
33923         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
33924         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33925         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33926         CVec_u8Z_free(ret_var);
33927         return ret_arr;
33928 }
33929
33930 uint64_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
33931         LDKu8slice ser_ref;
33932         ser_ref.datalen = ser->arr_len;
33933         ser_ref.data = ser->elems;
33934         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
33935         *ret_conv = RevokeAndACK_read(ser_ref);
33936         FREE(ser);
33937         return tag_ptr(ret_conv, true);
33938 }
33939
33940 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint64_t obj) {
33941         LDKShutdown obj_conv;
33942         obj_conv.inner = untag_ptr(obj);
33943         obj_conv.is_owned = ptr_is_owned(obj);
33944         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33945         obj_conv.is_owned = false;
33946         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
33947         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33948         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33949         CVec_u8Z_free(ret_var);
33950         return ret_arr;
33951 }
33952
33953 uint64_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
33954         LDKu8slice ser_ref;
33955         ser_ref.datalen = ser->arr_len;
33956         ser_ref.data = ser->elems;
33957         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
33958         *ret_conv = Shutdown_read(ser_ref);
33959         FREE(ser);
33960         return tag_ptr(ret_conv, true);
33961 }
33962
33963 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint64_t obj) {
33964         LDKUpdateFailHTLC obj_conv;
33965         obj_conv.inner = untag_ptr(obj);
33966         obj_conv.is_owned = ptr_is_owned(obj);
33967         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33968         obj_conv.is_owned = false;
33969         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
33970         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33971         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33972         CVec_u8Z_free(ret_var);
33973         return ret_arr;
33974 }
33975
33976 uint64_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
33977         LDKu8slice ser_ref;
33978         ser_ref.datalen = ser->arr_len;
33979         ser_ref.data = ser->elems;
33980         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
33981         *ret_conv = UpdateFailHTLC_read(ser_ref);
33982         FREE(ser);
33983         return tag_ptr(ret_conv, true);
33984 }
33985
33986 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint64_t obj) {
33987         LDKUpdateFailMalformedHTLC obj_conv;
33988         obj_conv.inner = untag_ptr(obj);
33989         obj_conv.is_owned = ptr_is_owned(obj);
33990         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33991         obj_conv.is_owned = false;
33992         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
33993         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33994         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33995         CVec_u8Z_free(ret_var);
33996         return ret_arr;
33997 }
33998
33999 uint64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
34000         LDKu8slice ser_ref;
34001         ser_ref.datalen = ser->arr_len;
34002         ser_ref.data = ser->elems;
34003         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
34004         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
34005         FREE(ser);
34006         return tag_ptr(ret_conv, true);
34007 }
34008
34009 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint64_t obj) {
34010         LDKUpdateFee obj_conv;
34011         obj_conv.inner = untag_ptr(obj);
34012         obj_conv.is_owned = ptr_is_owned(obj);
34013         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34014         obj_conv.is_owned = false;
34015         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
34016         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34017         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34018         CVec_u8Z_free(ret_var);
34019         return ret_arr;
34020 }
34021
34022 uint64_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
34023         LDKu8slice ser_ref;
34024         ser_ref.datalen = ser->arr_len;
34025         ser_ref.data = ser->elems;
34026         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
34027         *ret_conv = UpdateFee_read(ser_ref);
34028         FREE(ser);
34029         return tag_ptr(ret_conv, true);
34030 }
34031
34032 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint64_t obj) {
34033         LDKUpdateFulfillHTLC obj_conv;
34034         obj_conv.inner = untag_ptr(obj);
34035         obj_conv.is_owned = ptr_is_owned(obj);
34036         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34037         obj_conv.is_owned = false;
34038         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
34039         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34040         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34041         CVec_u8Z_free(ret_var);
34042         return ret_arr;
34043 }
34044
34045 uint64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
34046         LDKu8slice ser_ref;
34047         ser_ref.datalen = ser->arr_len;
34048         ser_ref.data = ser->elems;
34049         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
34050         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
34051         FREE(ser);
34052         return tag_ptr(ret_conv, true);
34053 }
34054
34055 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint64_t obj) {
34056         LDKUpdateAddHTLC obj_conv;
34057         obj_conv.inner = untag_ptr(obj);
34058         obj_conv.is_owned = ptr_is_owned(obj);
34059         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34060         obj_conv.is_owned = false;
34061         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
34062         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34063         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34064         CVec_u8Z_free(ret_var);
34065         return ret_arr;
34066 }
34067
34068 uint64_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
34069         LDKu8slice ser_ref;
34070         ser_ref.datalen = ser->arr_len;
34071         ser_ref.data = ser->elems;
34072         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
34073         *ret_conv = UpdateAddHTLC_read(ser_ref);
34074         FREE(ser);
34075         return tag_ptr(ret_conv, true);
34076 }
34077
34078 uint64_t  __attribute__((export_name("TS_OnionMessage_read"))) TS_OnionMessage_read(int8_tArray ser) {
34079         LDKu8slice ser_ref;
34080         ser_ref.datalen = ser->arr_len;
34081         ser_ref.data = ser->elems;
34082         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
34083         *ret_conv = OnionMessage_read(ser_ref);
34084         FREE(ser);
34085         return tag_ptr(ret_conv, true);
34086 }
34087
34088 int8_tArray  __attribute__((export_name("TS_OnionMessage_write"))) TS_OnionMessage_write(uint64_t obj) {
34089         LDKOnionMessage obj_conv;
34090         obj_conv.inner = untag_ptr(obj);
34091         obj_conv.is_owned = ptr_is_owned(obj);
34092         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34093         obj_conv.is_owned = false;
34094         LDKCVec_u8Z ret_var = OnionMessage_write(&obj_conv);
34095         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34096         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34097         CVec_u8Z_free(ret_var);
34098         return ret_arr;
34099 }
34100
34101 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint64_t obj) {
34102         LDKPing obj_conv;
34103         obj_conv.inner = untag_ptr(obj);
34104         obj_conv.is_owned = ptr_is_owned(obj);
34105         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34106         obj_conv.is_owned = false;
34107         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
34108         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34109         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34110         CVec_u8Z_free(ret_var);
34111         return ret_arr;
34112 }
34113
34114 uint64_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
34115         LDKu8slice ser_ref;
34116         ser_ref.datalen = ser->arr_len;
34117         ser_ref.data = ser->elems;
34118         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
34119         *ret_conv = Ping_read(ser_ref);
34120         FREE(ser);
34121         return tag_ptr(ret_conv, true);
34122 }
34123
34124 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint64_t obj) {
34125         LDKPong obj_conv;
34126         obj_conv.inner = untag_ptr(obj);
34127         obj_conv.is_owned = ptr_is_owned(obj);
34128         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34129         obj_conv.is_owned = false;
34130         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
34131         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34132         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34133         CVec_u8Z_free(ret_var);
34134         return ret_arr;
34135 }
34136
34137 uint64_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
34138         LDKu8slice ser_ref;
34139         ser_ref.datalen = ser->arr_len;
34140         ser_ref.data = ser->elems;
34141         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
34142         *ret_conv = Pong_read(ser_ref);
34143         FREE(ser);
34144         return tag_ptr(ret_conv, true);
34145 }
34146
34147 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint64_t obj) {
34148         LDKUnsignedChannelAnnouncement obj_conv;
34149         obj_conv.inner = untag_ptr(obj);
34150         obj_conv.is_owned = ptr_is_owned(obj);
34151         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34152         obj_conv.is_owned = false;
34153         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
34154         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34155         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34156         CVec_u8Z_free(ret_var);
34157         return ret_arr;
34158 }
34159
34160 uint64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
34161         LDKu8slice ser_ref;
34162         ser_ref.datalen = ser->arr_len;
34163         ser_ref.data = ser->elems;
34164         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
34165         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
34166         FREE(ser);
34167         return tag_ptr(ret_conv, true);
34168 }
34169
34170 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint64_t obj) {
34171         LDKChannelAnnouncement obj_conv;
34172         obj_conv.inner = untag_ptr(obj);
34173         obj_conv.is_owned = ptr_is_owned(obj);
34174         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34175         obj_conv.is_owned = false;
34176         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
34177         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34178         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34179         CVec_u8Z_free(ret_var);
34180         return ret_arr;
34181 }
34182
34183 uint64_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
34184         LDKu8slice ser_ref;
34185         ser_ref.datalen = ser->arr_len;
34186         ser_ref.data = ser->elems;
34187         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
34188         *ret_conv = ChannelAnnouncement_read(ser_ref);
34189         FREE(ser);
34190         return tag_ptr(ret_conv, true);
34191 }
34192
34193 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint64_t obj) {
34194         LDKUnsignedChannelUpdate obj_conv;
34195         obj_conv.inner = untag_ptr(obj);
34196         obj_conv.is_owned = ptr_is_owned(obj);
34197         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34198         obj_conv.is_owned = false;
34199         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
34200         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34201         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34202         CVec_u8Z_free(ret_var);
34203         return ret_arr;
34204 }
34205
34206 uint64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
34207         LDKu8slice ser_ref;
34208         ser_ref.datalen = ser->arr_len;
34209         ser_ref.data = ser->elems;
34210         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
34211         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
34212         FREE(ser);
34213         return tag_ptr(ret_conv, true);
34214 }
34215
34216 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint64_t obj) {
34217         LDKChannelUpdate obj_conv;
34218         obj_conv.inner = untag_ptr(obj);
34219         obj_conv.is_owned = ptr_is_owned(obj);
34220         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34221         obj_conv.is_owned = false;
34222         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
34223         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34224         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34225         CVec_u8Z_free(ret_var);
34226         return ret_arr;
34227 }
34228
34229 uint64_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
34230         LDKu8slice ser_ref;
34231         ser_ref.datalen = ser->arr_len;
34232         ser_ref.data = ser->elems;
34233         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
34234         *ret_conv = ChannelUpdate_read(ser_ref);
34235         FREE(ser);
34236         return tag_ptr(ret_conv, true);
34237 }
34238
34239 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint64_t obj) {
34240         LDKErrorMessage obj_conv;
34241         obj_conv.inner = untag_ptr(obj);
34242         obj_conv.is_owned = ptr_is_owned(obj);
34243         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34244         obj_conv.is_owned = false;
34245         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
34246         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34247         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34248         CVec_u8Z_free(ret_var);
34249         return ret_arr;
34250 }
34251
34252 uint64_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
34253         LDKu8slice ser_ref;
34254         ser_ref.datalen = ser->arr_len;
34255         ser_ref.data = ser->elems;
34256         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
34257         *ret_conv = ErrorMessage_read(ser_ref);
34258         FREE(ser);
34259         return tag_ptr(ret_conv, true);
34260 }
34261
34262 int8_tArray  __attribute__((export_name("TS_WarningMessage_write"))) TS_WarningMessage_write(uint64_t obj) {
34263         LDKWarningMessage obj_conv;
34264         obj_conv.inner = untag_ptr(obj);
34265         obj_conv.is_owned = ptr_is_owned(obj);
34266         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34267         obj_conv.is_owned = false;
34268         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
34269         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34270         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34271         CVec_u8Z_free(ret_var);
34272         return ret_arr;
34273 }
34274
34275 uint64_t  __attribute__((export_name("TS_WarningMessage_read"))) TS_WarningMessage_read(int8_tArray ser) {
34276         LDKu8slice ser_ref;
34277         ser_ref.datalen = ser->arr_len;
34278         ser_ref.data = ser->elems;
34279         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
34280         *ret_conv = WarningMessage_read(ser_ref);
34281         FREE(ser);
34282         return tag_ptr(ret_conv, true);
34283 }
34284
34285 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint64_t obj) {
34286         LDKUnsignedNodeAnnouncement obj_conv;
34287         obj_conv.inner = untag_ptr(obj);
34288         obj_conv.is_owned = ptr_is_owned(obj);
34289         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34290         obj_conv.is_owned = false;
34291         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
34292         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34293         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34294         CVec_u8Z_free(ret_var);
34295         return ret_arr;
34296 }
34297
34298 uint64_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
34299         LDKu8slice ser_ref;
34300         ser_ref.datalen = ser->arr_len;
34301         ser_ref.data = ser->elems;
34302         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
34303         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
34304         FREE(ser);
34305         return tag_ptr(ret_conv, true);
34306 }
34307
34308 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint64_t obj) {
34309         LDKNodeAnnouncement obj_conv;
34310         obj_conv.inner = untag_ptr(obj);
34311         obj_conv.is_owned = ptr_is_owned(obj);
34312         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34313         obj_conv.is_owned = false;
34314         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
34315         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34316         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34317         CVec_u8Z_free(ret_var);
34318         return ret_arr;
34319 }
34320
34321 uint64_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
34322         LDKu8slice ser_ref;
34323         ser_ref.datalen = ser->arr_len;
34324         ser_ref.data = ser->elems;
34325         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
34326         *ret_conv = NodeAnnouncement_read(ser_ref);
34327         FREE(ser);
34328         return tag_ptr(ret_conv, true);
34329 }
34330
34331 uint64_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
34332         LDKu8slice ser_ref;
34333         ser_ref.datalen = ser->arr_len;
34334         ser_ref.data = ser->elems;
34335         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
34336         *ret_conv = QueryShortChannelIds_read(ser_ref);
34337         FREE(ser);
34338         return tag_ptr(ret_conv, true);
34339 }
34340
34341 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint64_t obj) {
34342         LDKQueryShortChannelIds obj_conv;
34343         obj_conv.inner = untag_ptr(obj);
34344         obj_conv.is_owned = ptr_is_owned(obj);
34345         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34346         obj_conv.is_owned = false;
34347         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
34348         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34349         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34350         CVec_u8Z_free(ret_var);
34351         return ret_arr;
34352 }
34353
34354 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint64_t obj) {
34355         LDKReplyShortChannelIdsEnd obj_conv;
34356         obj_conv.inner = untag_ptr(obj);
34357         obj_conv.is_owned = ptr_is_owned(obj);
34358         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34359         obj_conv.is_owned = false;
34360         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
34361         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34362         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34363         CVec_u8Z_free(ret_var);
34364         return ret_arr;
34365 }
34366
34367 uint64_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
34368         LDKu8slice ser_ref;
34369         ser_ref.datalen = ser->arr_len;
34370         ser_ref.data = ser->elems;
34371         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
34372         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
34373         FREE(ser);
34374         return tag_ptr(ret_conv, true);
34375 }
34376
34377 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint64_t this_arg) {
34378         LDKQueryChannelRange this_arg_conv;
34379         this_arg_conv.inner = untag_ptr(this_arg);
34380         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34382         this_arg_conv.is_owned = false;
34383         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
34384         return ret_conv;
34385 }
34386
34387 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint64_t obj) {
34388         LDKQueryChannelRange obj_conv;
34389         obj_conv.inner = untag_ptr(obj);
34390         obj_conv.is_owned = ptr_is_owned(obj);
34391         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34392         obj_conv.is_owned = false;
34393         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
34394         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34395         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34396         CVec_u8Z_free(ret_var);
34397         return ret_arr;
34398 }
34399
34400 uint64_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
34401         LDKu8slice ser_ref;
34402         ser_ref.datalen = ser->arr_len;
34403         ser_ref.data = ser->elems;
34404         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
34405         *ret_conv = QueryChannelRange_read(ser_ref);
34406         FREE(ser);
34407         return tag_ptr(ret_conv, true);
34408 }
34409
34410 uint64_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
34411         LDKu8slice ser_ref;
34412         ser_ref.datalen = ser->arr_len;
34413         ser_ref.data = ser->elems;
34414         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
34415         *ret_conv = ReplyChannelRange_read(ser_ref);
34416         FREE(ser);
34417         return tag_ptr(ret_conv, true);
34418 }
34419
34420 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint64_t obj) {
34421         LDKReplyChannelRange obj_conv;
34422         obj_conv.inner = untag_ptr(obj);
34423         obj_conv.is_owned = ptr_is_owned(obj);
34424         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34425         obj_conv.is_owned = false;
34426         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
34427         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34428         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34429         CVec_u8Z_free(ret_var);
34430         return ret_arr;
34431 }
34432
34433 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint64_t obj) {
34434         LDKGossipTimestampFilter obj_conv;
34435         obj_conv.inner = untag_ptr(obj);
34436         obj_conv.is_owned = ptr_is_owned(obj);
34437         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34438         obj_conv.is_owned = false;
34439         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
34440         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34441         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34442         CVec_u8Z_free(ret_var);
34443         return ret_arr;
34444 }
34445
34446 uint64_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
34447         LDKu8slice ser_ref;
34448         ser_ref.datalen = ser->arr_len;
34449         ser_ref.data = ser->elems;
34450         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
34451         *ret_conv = GossipTimestampFilter_read(ser_ref);
34452         FREE(ser);
34453         return tag_ptr(ret_conv, true);
34454 }
34455
34456 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint64_t this_ptr) {
34457         if (!ptr_is_owned(this_ptr)) return;
34458         void* this_ptr_ptr = untag_ptr(this_ptr);
34459         CHECK_ACCESS(this_ptr_ptr);
34460         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
34461         FREE(untag_ptr(this_ptr));
34462         CustomMessageHandler_free(this_ptr_conv);
34463 }
34464
34465 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint64_t this_obj) {
34466         LDKIgnoringMessageHandler this_obj_conv;
34467         this_obj_conv.inner = untag_ptr(this_obj);
34468         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34470         IgnoringMessageHandler_free(this_obj_conv);
34471 }
34472
34473 uint64_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
34474         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
34475         uint64_t ret_ref = 0;
34476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34477         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34478         return ret_ref;
34479 }
34480
34481 uint64_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint64_t this_arg) {
34482         LDKIgnoringMessageHandler this_arg_conv;
34483         this_arg_conv.inner = untag_ptr(this_arg);
34484         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34486         this_arg_conv.is_owned = false;
34487         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
34488         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
34489         return tag_ptr(ret_ret, true);
34490 }
34491
34492 uint64_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint64_t this_arg) {
34493         LDKIgnoringMessageHandler this_arg_conv;
34494         this_arg_conv.inner = untag_ptr(this_arg);
34495         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34497         this_arg_conv.is_owned = false;
34498         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
34499         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
34500         return tag_ptr(ret_ret, true);
34501 }
34502
34503 uint64_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_OnionMessageProvider"))) TS_IgnoringMessageHandler_as_OnionMessageProvider(uint64_t this_arg) {
34504         LDKIgnoringMessageHandler this_arg_conv;
34505         this_arg_conv.inner = untag_ptr(this_arg);
34506         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34508         this_arg_conv.is_owned = false;
34509         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
34510         *ret_ret = IgnoringMessageHandler_as_OnionMessageProvider(&this_arg_conv);
34511         return tag_ptr(ret_ret, true);
34512 }
34513
34514 uint64_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_OnionMessageHandler"))) TS_IgnoringMessageHandler_as_OnionMessageHandler(uint64_t this_arg) {
34515         LDKIgnoringMessageHandler this_arg_conv;
34516         this_arg_conv.inner = untag_ptr(this_arg);
34517         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34519         this_arg_conv.is_owned = false;
34520         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
34521         *ret_ret = IgnoringMessageHandler_as_OnionMessageHandler(&this_arg_conv);
34522         return tag_ptr(ret_ret, true);
34523 }
34524
34525 uint64_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint64_t this_arg) {
34526         LDKIgnoringMessageHandler this_arg_conv;
34527         this_arg_conv.inner = untag_ptr(this_arg);
34528         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34530         this_arg_conv.is_owned = false;
34531         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
34532         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
34533         return tag_ptr(ret_ret, true);
34534 }
34535
34536 uint64_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint64_t this_arg) {
34537         LDKIgnoringMessageHandler this_arg_conv;
34538         this_arg_conv.inner = untag_ptr(this_arg);
34539         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34541         this_arg_conv.is_owned = false;
34542         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
34543         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
34544         return tag_ptr(ret_ret, true);
34545 }
34546
34547 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint64_t this_obj) {
34548         LDKErroringMessageHandler this_obj_conv;
34549         this_obj_conv.inner = untag_ptr(this_obj);
34550         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34552         ErroringMessageHandler_free(this_obj_conv);
34553 }
34554
34555 uint64_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
34556         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
34557         uint64_t ret_ref = 0;
34558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34559         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34560         return ret_ref;
34561 }
34562
34563 uint64_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint64_t this_arg) {
34564         LDKErroringMessageHandler this_arg_conv;
34565         this_arg_conv.inner = untag_ptr(this_arg);
34566         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34568         this_arg_conv.is_owned = false;
34569         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
34570         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
34571         return tag_ptr(ret_ret, true);
34572 }
34573
34574 uint64_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint64_t this_arg) {
34575         LDKErroringMessageHandler this_arg_conv;
34576         this_arg_conv.inner = untag_ptr(this_arg);
34577         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34579         this_arg_conv.is_owned = false;
34580         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
34581         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
34582         return tag_ptr(ret_ret, true);
34583 }
34584
34585 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint64_t this_obj) {
34586         LDKMessageHandler this_obj_conv;
34587         this_obj_conv.inner = untag_ptr(this_obj);
34588         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34590         MessageHandler_free(this_obj_conv);
34591 }
34592
34593 uint64_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint64_t this_ptr) {
34594         LDKMessageHandler this_ptr_conv;
34595         this_ptr_conv.inner = untag_ptr(this_ptr);
34596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34598         this_ptr_conv.is_owned = false;
34599         // WARNING: This object doesn't live past this scope, needs clone!
34600         uint64_t ret_ret = tag_ptr(MessageHandler_get_chan_handler(&this_ptr_conv), false);
34601         return ret_ret;
34602 }
34603
34604 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint64_t this_ptr, uint64_t val) {
34605         LDKMessageHandler this_ptr_conv;
34606         this_ptr_conv.inner = untag_ptr(this_ptr);
34607         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34609         this_ptr_conv.is_owned = false;
34610         void* val_ptr = untag_ptr(val);
34611         CHECK_ACCESS(val_ptr);
34612         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
34613         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
34614                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34615                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
34616         }
34617         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
34618 }
34619
34620 uint64_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint64_t this_ptr) {
34621         LDKMessageHandler this_ptr_conv;
34622         this_ptr_conv.inner = untag_ptr(this_ptr);
34623         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34625         this_ptr_conv.is_owned = false;
34626         // WARNING: This object doesn't live past this scope, needs clone!
34627         uint64_t ret_ret = tag_ptr(MessageHandler_get_route_handler(&this_ptr_conv), false);
34628         return ret_ret;
34629 }
34630
34631 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint64_t this_ptr, uint64_t val) {
34632         LDKMessageHandler this_ptr_conv;
34633         this_ptr_conv.inner = untag_ptr(this_ptr);
34634         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34636         this_ptr_conv.is_owned = false;
34637         void* val_ptr = untag_ptr(val);
34638         CHECK_ACCESS(val_ptr);
34639         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
34640         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
34641                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34642                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
34643         }
34644         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
34645 }
34646
34647 uint64_t  __attribute__((export_name("TS_MessageHandler_get_onion_message_handler"))) TS_MessageHandler_get_onion_message_handler(uint64_t this_ptr) {
34648         LDKMessageHandler this_ptr_conv;
34649         this_ptr_conv.inner = untag_ptr(this_ptr);
34650         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34652         this_ptr_conv.is_owned = false;
34653         // WARNING: This object doesn't live past this scope, needs clone!
34654         uint64_t ret_ret = tag_ptr(MessageHandler_get_onion_message_handler(&this_ptr_conv), false);
34655         return ret_ret;
34656 }
34657
34658 void  __attribute__((export_name("TS_MessageHandler_set_onion_message_handler"))) TS_MessageHandler_set_onion_message_handler(uint64_t this_ptr, uint64_t val) {
34659         LDKMessageHandler this_ptr_conv;
34660         this_ptr_conv.inner = untag_ptr(this_ptr);
34661         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34663         this_ptr_conv.is_owned = false;
34664         void* val_ptr = untag_ptr(val);
34665         CHECK_ACCESS(val_ptr);
34666         LDKOnionMessageHandler val_conv = *(LDKOnionMessageHandler*)(val_ptr);
34667         if (val_conv.free == LDKOnionMessageHandler_JCalls_free) {
34668                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34669                 LDKOnionMessageHandler_JCalls_cloned(&val_conv);
34670         }
34671         MessageHandler_set_onion_message_handler(&this_ptr_conv, val_conv);
34672 }
34673
34674 uint64_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint64_t chan_handler_arg, uint64_t route_handler_arg, uint64_t onion_message_handler_arg) {
34675         void* chan_handler_arg_ptr = untag_ptr(chan_handler_arg);
34676         CHECK_ACCESS(chan_handler_arg_ptr);
34677         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
34678         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
34679                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34680                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
34681         }
34682         void* route_handler_arg_ptr = untag_ptr(route_handler_arg);
34683         CHECK_ACCESS(route_handler_arg_ptr);
34684         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
34685         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
34686                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34687                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
34688         }
34689         void* onion_message_handler_arg_ptr = untag_ptr(onion_message_handler_arg);
34690         CHECK_ACCESS(onion_message_handler_arg_ptr);
34691         LDKOnionMessageHandler onion_message_handler_arg_conv = *(LDKOnionMessageHandler*)(onion_message_handler_arg_ptr);
34692         if (onion_message_handler_arg_conv.free == LDKOnionMessageHandler_JCalls_free) {
34693                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34694                 LDKOnionMessageHandler_JCalls_cloned(&onion_message_handler_arg_conv);
34695         }
34696         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv, onion_message_handler_arg_conv);
34697         uint64_t ret_ref = 0;
34698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34699         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34700         return ret_ref;
34701 }
34702
34703 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
34704         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
34705         *ret_ret = SocketDescriptor_clone(arg);
34706         return tag_ptr(ret_ret, true);
34707 }
34708 int64_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint64_t arg) {
34709         void* arg_ptr = untag_ptr(arg);
34710         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
34711         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
34712         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
34713         return ret_conv;
34714 }
34715
34716 uint64_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint64_t orig) {
34717         void* orig_ptr = untag_ptr(orig);
34718         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
34719         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
34720         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
34721         *ret_ret = SocketDescriptor_clone(orig_conv);
34722         return tag_ptr(ret_ret, true);
34723 }
34724
34725 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint64_t this_ptr) {
34726         if (!ptr_is_owned(this_ptr)) return;
34727         void* this_ptr_ptr = untag_ptr(this_ptr);
34728         CHECK_ACCESS(this_ptr_ptr);
34729         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
34730         FREE(untag_ptr(this_ptr));
34731         SocketDescriptor_free(this_ptr_conv);
34732 }
34733
34734 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint64_t this_obj) {
34735         LDKPeerHandleError this_obj_conv;
34736         this_obj_conv.inner = untag_ptr(this_obj);
34737         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34739         PeerHandleError_free(this_obj_conv);
34740 }
34741
34742 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint64_t this_ptr) {
34743         LDKPeerHandleError this_ptr_conv;
34744         this_ptr_conv.inner = untag_ptr(this_ptr);
34745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34747         this_ptr_conv.is_owned = false;
34748         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
34749         return ret_conv;
34750 }
34751
34752 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint64_t this_ptr, jboolean val) {
34753         LDKPeerHandleError this_ptr_conv;
34754         this_ptr_conv.inner = untag_ptr(this_ptr);
34755         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34757         this_ptr_conv.is_owned = false;
34758         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
34759 }
34760
34761 uint64_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
34762         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
34763         uint64_t ret_ref = 0;
34764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34765         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34766         return ret_ref;
34767 }
34768
34769 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
34770         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
34771         uint64_t ret_ref = 0;
34772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34773         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34774         return ret_ref;
34775 }
34776 int64_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint64_t arg) {
34777         LDKPeerHandleError arg_conv;
34778         arg_conv.inner = untag_ptr(arg);
34779         arg_conv.is_owned = ptr_is_owned(arg);
34780         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34781         arg_conv.is_owned = false;
34782         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
34783         return ret_conv;
34784 }
34785
34786 uint64_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint64_t orig) {
34787         LDKPeerHandleError orig_conv;
34788         orig_conv.inner = untag_ptr(orig);
34789         orig_conv.is_owned = ptr_is_owned(orig);
34790         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34791         orig_conv.is_owned = false;
34792         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
34793         uint64_t ret_ref = 0;
34794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34795         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34796         return ret_ref;
34797 }
34798
34799 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint64_t this_obj) {
34800         LDKPeerManager this_obj_conv;
34801         this_obj_conv.inner = untag_ptr(this_obj);
34802         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34804         PeerManager_free(this_obj_conv);
34805 }
34806
34807 uint64_t  __attribute__((export_name("TS_PeerManager_new"))) TS_PeerManager_new(uint64_t message_handler, int8_tArray our_node_secret, int64_t current_time, int8_tArray ephemeral_random_data, uint64_t logger, uint64_t custom_message_handler) {
34808         LDKMessageHandler message_handler_conv;
34809         message_handler_conv.inner = untag_ptr(message_handler);
34810         message_handler_conv.is_owned = ptr_is_owned(message_handler);
34811         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
34812         // WARNING: we need a move here but no clone is available for LDKMessageHandler
34813         
34814         LDKSecretKey our_node_secret_ref;
34815         CHECK(our_node_secret->arr_len == 32);
34816         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
34817         unsigned char ephemeral_random_data_arr[32];
34818         CHECK(ephemeral_random_data->arr_len == 32);
34819         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
34820         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
34821         void* logger_ptr = untag_ptr(logger);
34822         CHECK_ACCESS(logger_ptr);
34823         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34824         if (logger_conv.free == LDKLogger_JCalls_free) {
34825                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34826                 LDKLogger_JCalls_cloned(&logger_conv);
34827         }
34828         void* custom_message_handler_ptr = untag_ptr(custom_message_handler);
34829         CHECK_ACCESS(custom_message_handler_ptr);
34830         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
34831         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
34832                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34833                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
34834         }
34835         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, current_time, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
34836         uint64_t ret_ref = 0;
34837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34838         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34839         return ret_ref;
34840 }
34841
34842 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint64_t this_arg) {
34843         LDKPeerManager this_arg_conv;
34844         this_arg_conv.inner = untag_ptr(this_arg);
34845         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34847         this_arg_conv.is_owned = false;
34848         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
34849         ptrArray ret_arr = NULL;
34850         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
34851         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
34852         for (size_t m = 0; m < ret_var.datalen; m++) {
34853                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
34854                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
34855                 ret_arr_ptr[m] = ret_conv_12_arr;
34856         }
34857         
34858         FREE(ret_var.data);
34859         return ret_arr;
34860 }
34861
34862 uint64_t  __attribute__((export_name("TS_PeerManager_new_outbound_connection"))) TS_PeerManager_new_outbound_connection(uint64_t this_arg, int8_tArray their_node_id, uint64_t descriptor, uint64_t remote_network_address) {
34863         LDKPeerManager this_arg_conv;
34864         this_arg_conv.inner = untag_ptr(this_arg);
34865         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34867         this_arg_conv.is_owned = false;
34868         LDKPublicKey their_node_id_ref;
34869         CHECK(their_node_id->arr_len == 33);
34870         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
34871         void* descriptor_ptr = untag_ptr(descriptor);
34872         CHECK_ACCESS(descriptor_ptr);
34873         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
34874         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
34875                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34876                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
34877         }
34878         void* remote_network_address_ptr = untag_ptr(remote_network_address);
34879         CHECK_ACCESS(remote_network_address_ptr);
34880         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
34881         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
34882         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
34883         return tag_ptr(ret_conv, true);
34884 }
34885
34886 uint64_t  __attribute__((export_name("TS_PeerManager_new_inbound_connection"))) TS_PeerManager_new_inbound_connection(uint64_t this_arg, uint64_t descriptor, uint64_t remote_network_address) {
34887         LDKPeerManager this_arg_conv;
34888         this_arg_conv.inner = untag_ptr(this_arg);
34889         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34891         this_arg_conv.is_owned = false;
34892         void* descriptor_ptr = untag_ptr(descriptor);
34893         CHECK_ACCESS(descriptor_ptr);
34894         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
34895         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
34896                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34897                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
34898         }
34899         void* remote_network_address_ptr = untag_ptr(remote_network_address);
34900         CHECK_ACCESS(remote_network_address_ptr);
34901         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
34902         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
34903         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
34904         return tag_ptr(ret_conv, true);
34905 }
34906
34907 uint64_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint64_t this_arg, uint64_t descriptor) {
34908         LDKPeerManager this_arg_conv;
34909         this_arg_conv.inner = untag_ptr(this_arg);
34910         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34912         this_arg_conv.is_owned = false;
34913         void* descriptor_ptr = untag_ptr(descriptor);
34914         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
34915         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
34916         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
34917         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
34918         return tag_ptr(ret_conv, true);
34919 }
34920
34921 uint64_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint64_t this_arg, uint64_t peer_descriptor, int8_tArray data) {
34922         LDKPeerManager this_arg_conv;
34923         this_arg_conv.inner = untag_ptr(this_arg);
34924         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34926         this_arg_conv.is_owned = false;
34927         void* peer_descriptor_ptr = untag_ptr(peer_descriptor);
34928         if (ptr_is_owned(peer_descriptor)) { CHECK_ACCESS(peer_descriptor_ptr); }
34929         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
34930         LDKu8slice data_ref;
34931         data_ref.datalen = data->arr_len;
34932         data_ref.data = data->elems;
34933         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
34934         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
34935         FREE(data);
34936         return tag_ptr(ret_conv, true);
34937 }
34938
34939 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint64_t this_arg) {
34940         LDKPeerManager this_arg_conv;
34941         this_arg_conv.inner = untag_ptr(this_arg);
34942         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34944         this_arg_conv.is_owned = false;
34945         PeerManager_process_events(&this_arg_conv);
34946 }
34947
34948 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint64_t this_arg, uint64_t descriptor) {
34949         LDKPeerManager this_arg_conv;
34950         this_arg_conv.inner = untag_ptr(this_arg);
34951         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34953         this_arg_conv.is_owned = false;
34954         void* descriptor_ptr = untag_ptr(descriptor);
34955         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
34956         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
34957         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
34958 }
34959
34960 void  __attribute__((export_name("TS_PeerManager_disconnect_by_node_id"))) TS_PeerManager_disconnect_by_node_id(uint64_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
34961         LDKPeerManager this_arg_conv;
34962         this_arg_conv.inner = untag_ptr(this_arg);
34963         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34965         this_arg_conv.is_owned = false;
34966         LDKPublicKey node_id_ref;
34967         CHECK(node_id->arr_len == 33);
34968         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
34969         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
34970 }
34971
34972 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint64_t this_arg) {
34973         LDKPeerManager this_arg_conv;
34974         this_arg_conv.inner = untag_ptr(this_arg);
34975         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34977         this_arg_conv.is_owned = false;
34978         PeerManager_disconnect_all_peers(&this_arg_conv);
34979 }
34980
34981 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint64_t this_arg) {
34982         LDKPeerManager this_arg_conv;
34983         this_arg_conv.inner = untag_ptr(this_arg);
34984         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34986         this_arg_conv.is_owned = false;
34987         PeerManager_timer_tick_occurred(&this_arg_conv);
34988 }
34989
34990 void  __attribute__((export_name("TS_PeerManager_broadcast_node_announcement"))) TS_PeerManager_broadcast_node_announcement(uint64_t this_arg, int8_tArray rgb, int8_tArray alias, uint64_tArray addresses) {
34991         LDKPeerManager this_arg_conv;
34992         this_arg_conv.inner = untag_ptr(this_arg);
34993         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34995         this_arg_conv.is_owned = false;
34996         LDKThreeBytes rgb_ref;
34997         CHECK(rgb->arr_len == 3);
34998         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
34999         LDKThirtyTwoBytes alias_ref;
35000         CHECK(alias->arr_len == 32);
35001         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
35002         LDKCVec_NetAddressZ addresses_constr;
35003         addresses_constr.datalen = addresses->arr_len;
35004         if (addresses_constr.datalen > 0)
35005                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
35006         else
35007                 addresses_constr.data = NULL;
35008         uint64_t* addresses_vals = addresses->elems;
35009         for (size_t m = 0; m < addresses_constr.datalen; m++) {
35010                 uint64_t addresses_conv_12 = addresses_vals[m];
35011                 void* addresses_conv_12_ptr = untag_ptr(addresses_conv_12);
35012                 CHECK_ACCESS(addresses_conv_12_ptr);
35013                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
35014                 addresses_constr.data[m] = addresses_conv_12_conv;
35015         }
35016         FREE(addresses);
35017         PeerManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
35018 }
35019
35020 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
35021         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
35022         return ret_conv;
35023 }
35024
35025 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
35026         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
35027         return ret_conv;
35028 }
35029
35030 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
35031         unsigned char commitment_seed_arr[32];
35032         CHECK(commitment_seed->arr_len == 32);
35033         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
35034         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
35035         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35036         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
35037         return ret_arr;
35038 }
35039
35040 int8_tArray  __attribute__((export_name("TS_build_closing_transaction"))) TS_build_closing_transaction(int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, uint64_t funding_outpoint) {
35041         LDKCVec_u8Z to_holder_script_ref;
35042         to_holder_script_ref.datalen = to_holder_script->arr_len;
35043         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
35044         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
35045         LDKCVec_u8Z to_counterparty_script_ref;
35046         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
35047         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
35048         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
35049         LDKOutPoint funding_outpoint_conv;
35050         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
35051         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
35052         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
35053         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
35054         LDKTransaction ret_var = build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
35055         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35056         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35057         Transaction_free(ret_var);
35058         return ret_arr;
35059 }
35060
35061 void  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_free"))) TS_CounterpartyCommitmentSecrets_free(uint64_t this_obj) {
35062         LDKCounterpartyCommitmentSecrets this_obj_conv;
35063         this_obj_conv.inner = untag_ptr(this_obj);
35064         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35066         CounterpartyCommitmentSecrets_free(this_obj_conv);
35067 }
35068
35069 static inline uint64_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
35070         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
35071         uint64_t ret_ref = 0;
35072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35073         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35074         return ret_ref;
35075 }
35076 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone_ptr"))) TS_CounterpartyCommitmentSecrets_clone_ptr(uint64_t arg) {
35077         LDKCounterpartyCommitmentSecrets arg_conv;
35078         arg_conv.inner = untag_ptr(arg);
35079         arg_conv.is_owned = ptr_is_owned(arg);
35080         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35081         arg_conv.is_owned = false;
35082         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
35083         return ret_conv;
35084 }
35085
35086 uint64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone"))) TS_CounterpartyCommitmentSecrets_clone(uint64_t orig) {
35087         LDKCounterpartyCommitmentSecrets orig_conv;
35088         orig_conv.inner = untag_ptr(orig);
35089         orig_conv.is_owned = ptr_is_owned(orig);
35090         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35091         orig_conv.is_owned = false;
35092         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
35093         uint64_t ret_ref = 0;
35094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35095         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35096         return ret_ref;
35097 }
35098
35099 uint64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_new"))) TS_CounterpartyCommitmentSecrets_new() {
35100         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
35101         uint64_t ret_ref = 0;
35102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35103         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35104         return ret_ref;
35105 }
35106
35107 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_min_seen_secret"))) TS_CounterpartyCommitmentSecrets_get_min_seen_secret(uint64_t this_arg) {
35108         LDKCounterpartyCommitmentSecrets this_arg_conv;
35109         this_arg_conv.inner = untag_ptr(this_arg);
35110         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35112         this_arg_conv.is_owned = false;
35113         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
35114         return ret_conv;
35115 }
35116
35117 uint64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_provide_secret"))) TS_CounterpartyCommitmentSecrets_provide_secret(uint64_t this_arg, int64_t idx, int8_tArray secret) {
35118         LDKCounterpartyCommitmentSecrets this_arg_conv;
35119         this_arg_conv.inner = untag_ptr(this_arg);
35120         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35122         this_arg_conv.is_owned = false;
35123         LDKThirtyTwoBytes secret_ref;
35124         CHECK(secret->arr_len == 32);
35125         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
35126         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
35127         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
35128         return tag_ptr(ret_conv, true);
35129 }
35130
35131 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_secret"))) TS_CounterpartyCommitmentSecrets_get_secret(uint64_t this_arg, int64_t idx) {
35132         LDKCounterpartyCommitmentSecrets this_arg_conv;
35133         this_arg_conv.inner = untag_ptr(this_arg);
35134         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35136         this_arg_conv.is_owned = false;
35137         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35138         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
35139         return ret_arr;
35140 }
35141
35142 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_write"))) TS_CounterpartyCommitmentSecrets_write(uint64_t obj) {
35143         LDKCounterpartyCommitmentSecrets obj_conv;
35144         obj_conv.inner = untag_ptr(obj);
35145         obj_conv.is_owned = ptr_is_owned(obj);
35146         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35147         obj_conv.is_owned = false;
35148         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
35149         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35150         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35151         CVec_u8Z_free(ret_var);
35152         return ret_arr;
35153 }
35154
35155 uint64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_read"))) TS_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
35156         LDKu8slice ser_ref;
35157         ser_ref.datalen = ser->arr_len;
35158         ser_ref.data = ser->elems;
35159         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
35160         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
35161         FREE(ser);
35162         return tag_ptr(ret_conv, true);
35163 }
35164
35165 uint64_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
35166         LDKPublicKey per_commitment_point_ref;
35167         CHECK(per_commitment_point->arr_len == 33);
35168         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35169         unsigned char base_secret_arr[32];
35170         CHECK(base_secret->arr_len == 32);
35171         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
35172         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
35173         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
35174         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
35175         return tag_ptr(ret_conv, true);
35176 }
35177
35178 uint64_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
35179         LDKPublicKey per_commitment_point_ref;
35180         CHECK(per_commitment_point->arr_len == 33);
35181         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35182         LDKPublicKey base_point_ref;
35183         CHECK(base_point->arr_len == 33);
35184         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
35185         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
35186         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
35187         return tag_ptr(ret_conv, true);
35188 }
35189
35190 uint64_t  __attribute__((export_name("TS_derive_private_revocation_key"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
35191         unsigned char per_commitment_secret_arr[32];
35192         CHECK(per_commitment_secret->arr_len == 32);
35193         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
35194         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
35195         unsigned char countersignatory_revocation_base_secret_arr[32];
35196         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
35197         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
35198         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
35199         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
35200         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
35201         return tag_ptr(ret_conv, true);
35202 }
35203
35204 uint64_t  __attribute__((export_name("TS_derive_public_revocation_key"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
35205         LDKPublicKey per_commitment_point_ref;
35206         CHECK(per_commitment_point->arr_len == 33);
35207         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35208         LDKPublicKey countersignatory_revocation_base_point_ref;
35209         CHECK(countersignatory_revocation_base_point->arr_len == 33);
35210         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
35211         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
35212         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
35213         return tag_ptr(ret_conv, true);
35214 }
35215
35216 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint64_t this_obj) {
35217         LDKTxCreationKeys this_obj_conv;
35218         this_obj_conv.inner = untag_ptr(this_obj);
35219         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35221         TxCreationKeys_free(this_obj_conv);
35222 }
35223
35224 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint64_t this_ptr) {
35225         LDKTxCreationKeys this_ptr_conv;
35226         this_ptr_conv.inner = untag_ptr(this_ptr);
35227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35229         this_ptr_conv.is_owned = false;
35230         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35231         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
35232         return ret_arr;
35233 }
35234
35235 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint64_t this_ptr, int8_tArray val) {
35236         LDKTxCreationKeys this_ptr_conv;
35237         this_ptr_conv.inner = untag_ptr(this_ptr);
35238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35240         this_ptr_conv.is_owned = false;
35241         LDKPublicKey val_ref;
35242         CHECK(val->arr_len == 33);
35243         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35244         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
35245 }
35246
35247 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint64_t this_ptr) {
35248         LDKTxCreationKeys this_ptr_conv;
35249         this_ptr_conv.inner = untag_ptr(this_ptr);
35250         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35252         this_ptr_conv.is_owned = false;
35253         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35254         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
35255         return ret_arr;
35256 }
35257
35258 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint64_t this_ptr, int8_tArray val) {
35259         LDKTxCreationKeys this_ptr_conv;
35260         this_ptr_conv.inner = untag_ptr(this_ptr);
35261         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35263         this_ptr_conv.is_owned = false;
35264         LDKPublicKey val_ref;
35265         CHECK(val->arr_len == 33);
35266         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35267         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
35268 }
35269
35270 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint64_t this_ptr) {
35271         LDKTxCreationKeys this_ptr_conv;
35272         this_ptr_conv.inner = untag_ptr(this_ptr);
35273         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35275         this_ptr_conv.is_owned = false;
35276         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35277         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
35278         return ret_arr;
35279 }
35280
35281 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint64_t this_ptr, int8_tArray val) {
35282         LDKTxCreationKeys this_ptr_conv;
35283         this_ptr_conv.inner = untag_ptr(this_ptr);
35284         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35286         this_ptr_conv.is_owned = false;
35287         LDKPublicKey val_ref;
35288         CHECK(val->arr_len == 33);
35289         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35290         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
35291 }
35292
35293 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint64_t this_ptr) {
35294         LDKTxCreationKeys this_ptr_conv;
35295         this_ptr_conv.inner = untag_ptr(this_ptr);
35296         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35298         this_ptr_conv.is_owned = false;
35299         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35300         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
35301         return ret_arr;
35302 }
35303
35304 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint64_t this_ptr, int8_tArray val) {
35305         LDKTxCreationKeys this_ptr_conv;
35306         this_ptr_conv.inner = untag_ptr(this_ptr);
35307         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35309         this_ptr_conv.is_owned = false;
35310         LDKPublicKey val_ref;
35311         CHECK(val->arr_len == 33);
35312         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35313         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
35314 }
35315
35316 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint64_t this_ptr) {
35317         LDKTxCreationKeys this_ptr_conv;
35318         this_ptr_conv.inner = untag_ptr(this_ptr);
35319         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35321         this_ptr_conv.is_owned = false;
35322         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35323         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
35324         return ret_arr;
35325 }
35326
35327 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint64_t this_ptr, int8_tArray val) {
35328         LDKTxCreationKeys this_ptr_conv;
35329         this_ptr_conv.inner = untag_ptr(this_ptr);
35330         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35332         this_ptr_conv.is_owned = false;
35333         LDKPublicKey val_ref;
35334         CHECK(val->arr_len == 33);
35335         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35336         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
35337 }
35338
35339 uint64_t  __attribute__((export_name("TS_TxCreationKeys_new"))) 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) {
35340         LDKPublicKey per_commitment_point_arg_ref;
35341         CHECK(per_commitment_point_arg->arr_len == 33);
35342         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
35343         LDKPublicKey revocation_key_arg_ref;
35344         CHECK(revocation_key_arg->arr_len == 33);
35345         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
35346         LDKPublicKey broadcaster_htlc_key_arg_ref;
35347         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
35348         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
35349         LDKPublicKey countersignatory_htlc_key_arg_ref;
35350         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
35351         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
35352         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
35353         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
35354         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
35355         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);
35356         uint64_t ret_ref = 0;
35357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35358         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35359         return ret_ref;
35360 }
35361
35362 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
35363         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
35364         uint64_t ret_ref = 0;
35365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35366         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35367         return ret_ref;
35368 }
35369 int64_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint64_t arg) {
35370         LDKTxCreationKeys arg_conv;
35371         arg_conv.inner = untag_ptr(arg);
35372         arg_conv.is_owned = ptr_is_owned(arg);
35373         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35374         arg_conv.is_owned = false;
35375         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
35376         return ret_conv;
35377 }
35378
35379 uint64_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint64_t orig) {
35380         LDKTxCreationKeys orig_conv;
35381         orig_conv.inner = untag_ptr(orig);
35382         orig_conv.is_owned = ptr_is_owned(orig);
35383         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35384         orig_conv.is_owned = false;
35385         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
35386         uint64_t ret_ref = 0;
35387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35388         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35389         return ret_ref;
35390 }
35391
35392 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint64_t obj) {
35393         LDKTxCreationKeys obj_conv;
35394         obj_conv.inner = untag_ptr(obj);
35395         obj_conv.is_owned = ptr_is_owned(obj);
35396         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35397         obj_conv.is_owned = false;
35398         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
35399         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35400         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35401         CVec_u8Z_free(ret_var);
35402         return ret_arr;
35403 }
35404
35405 uint64_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
35406         LDKu8slice ser_ref;
35407         ser_ref.datalen = ser->arr_len;
35408         ser_ref.data = ser->elems;
35409         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
35410         *ret_conv = TxCreationKeys_read(ser_ref);
35411         FREE(ser);
35412         return tag_ptr(ret_conv, true);
35413 }
35414
35415 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint64_t this_obj) {
35416         LDKChannelPublicKeys this_obj_conv;
35417         this_obj_conv.inner = untag_ptr(this_obj);
35418         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35420         ChannelPublicKeys_free(this_obj_conv);
35421 }
35422
35423 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint64_t this_ptr) {
35424         LDKChannelPublicKeys this_ptr_conv;
35425         this_ptr_conv.inner = untag_ptr(this_ptr);
35426         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35428         this_ptr_conv.is_owned = false;
35429         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35430         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
35431         return ret_arr;
35432 }
35433
35434 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint64_t this_ptr, int8_tArray val) {
35435         LDKChannelPublicKeys this_ptr_conv;
35436         this_ptr_conv.inner = untag_ptr(this_ptr);
35437         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35439         this_ptr_conv.is_owned = false;
35440         LDKPublicKey val_ref;
35441         CHECK(val->arr_len == 33);
35442         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35443         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
35444 }
35445
35446 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint64_t this_ptr) {
35447         LDKChannelPublicKeys this_ptr_conv;
35448         this_ptr_conv.inner = untag_ptr(this_ptr);
35449         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35451         this_ptr_conv.is_owned = false;
35452         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35453         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
35454         return ret_arr;
35455 }
35456
35457 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint64_t this_ptr, int8_tArray val) {
35458         LDKChannelPublicKeys this_ptr_conv;
35459         this_ptr_conv.inner = untag_ptr(this_ptr);
35460         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35462         this_ptr_conv.is_owned = false;
35463         LDKPublicKey val_ref;
35464         CHECK(val->arr_len == 33);
35465         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35466         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
35467 }
35468
35469 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint64_t this_ptr) {
35470         LDKChannelPublicKeys this_ptr_conv;
35471         this_ptr_conv.inner = untag_ptr(this_ptr);
35472         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35474         this_ptr_conv.is_owned = false;
35475         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35476         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
35477         return ret_arr;
35478 }
35479
35480 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint64_t this_ptr, int8_tArray val) {
35481         LDKChannelPublicKeys this_ptr_conv;
35482         this_ptr_conv.inner = untag_ptr(this_ptr);
35483         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35485         this_ptr_conv.is_owned = false;
35486         LDKPublicKey val_ref;
35487         CHECK(val->arr_len == 33);
35488         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35489         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
35490 }
35491
35492 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint64_t this_ptr) {
35493         LDKChannelPublicKeys this_ptr_conv;
35494         this_ptr_conv.inner = untag_ptr(this_ptr);
35495         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35497         this_ptr_conv.is_owned = false;
35498         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35499         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
35500         return ret_arr;
35501 }
35502
35503 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint64_t this_ptr, int8_tArray val) {
35504         LDKChannelPublicKeys this_ptr_conv;
35505         this_ptr_conv.inner = untag_ptr(this_ptr);
35506         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35508         this_ptr_conv.is_owned = false;
35509         LDKPublicKey val_ref;
35510         CHECK(val->arr_len == 33);
35511         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35512         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35513 }
35514
35515 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint64_t this_ptr) {
35516         LDKChannelPublicKeys this_ptr_conv;
35517         this_ptr_conv.inner = untag_ptr(this_ptr);
35518         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35520         this_ptr_conv.is_owned = false;
35521         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35522         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
35523         return ret_arr;
35524 }
35525
35526 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint64_t this_ptr, int8_tArray val) {
35527         LDKChannelPublicKeys this_ptr_conv;
35528         this_ptr_conv.inner = untag_ptr(this_ptr);
35529         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35531         this_ptr_conv.is_owned = false;
35532         LDKPublicKey val_ref;
35533         CHECK(val->arr_len == 33);
35534         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35535         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
35536 }
35537
35538 uint64_t  __attribute__((export_name("TS_ChannelPublicKeys_new"))) 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) {
35539         LDKPublicKey funding_pubkey_arg_ref;
35540         CHECK(funding_pubkey_arg->arr_len == 33);
35541         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
35542         LDKPublicKey revocation_basepoint_arg_ref;
35543         CHECK(revocation_basepoint_arg->arr_len == 33);
35544         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
35545         LDKPublicKey payment_point_arg_ref;
35546         CHECK(payment_point_arg->arr_len == 33);
35547         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
35548         LDKPublicKey delayed_payment_basepoint_arg_ref;
35549         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
35550         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
35551         LDKPublicKey htlc_basepoint_arg_ref;
35552         CHECK(htlc_basepoint_arg->arr_len == 33);
35553         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
35554         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);
35555         uint64_t ret_ref = 0;
35556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35557         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35558         return ret_ref;
35559 }
35560
35561 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
35562         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
35563         uint64_t ret_ref = 0;
35564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35565         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35566         return ret_ref;
35567 }
35568 int64_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint64_t arg) {
35569         LDKChannelPublicKeys arg_conv;
35570         arg_conv.inner = untag_ptr(arg);
35571         arg_conv.is_owned = ptr_is_owned(arg);
35572         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35573         arg_conv.is_owned = false;
35574         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
35575         return ret_conv;
35576 }
35577
35578 uint64_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint64_t orig) {
35579         LDKChannelPublicKeys orig_conv;
35580         orig_conv.inner = untag_ptr(orig);
35581         orig_conv.is_owned = ptr_is_owned(orig);
35582         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35583         orig_conv.is_owned = false;
35584         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
35585         uint64_t ret_ref = 0;
35586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35587         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35588         return ret_ref;
35589 }
35590
35591 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint64_t obj) {
35592         LDKChannelPublicKeys obj_conv;
35593         obj_conv.inner = untag_ptr(obj);
35594         obj_conv.is_owned = ptr_is_owned(obj);
35595         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35596         obj_conv.is_owned = false;
35597         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
35598         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35599         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35600         CVec_u8Z_free(ret_var);
35601         return ret_arr;
35602 }
35603
35604 uint64_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
35605         LDKu8slice ser_ref;
35606         ser_ref.datalen = ser->arr_len;
35607         ser_ref.data = ser->elems;
35608         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
35609         *ret_conv = ChannelPublicKeys_read(ser_ref);
35610         FREE(ser);
35611         return tag_ptr(ret_conv, true);
35612 }
35613
35614 uint64_t  __attribute__((export_name("TS_TxCreationKeys_derive_new"))) 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) {
35615         LDKPublicKey per_commitment_point_ref;
35616         CHECK(per_commitment_point->arr_len == 33);
35617         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35618         LDKPublicKey broadcaster_delayed_payment_base_ref;
35619         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
35620         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
35621         LDKPublicKey broadcaster_htlc_base_ref;
35622         CHECK(broadcaster_htlc_base->arr_len == 33);
35623         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
35624         LDKPublicKey countersignatory_revocation_base_ref;
35625         CHECK(countersignatory_revocation_base->arr_len == 33);
35626         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
35627         LDKPublicKey countersignatory_htlc_base_ref;
35628         CHECK(countersignatory_htlc_base->arr_len == 33);
35629         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
35630         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
35631         *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);
35632         return tag_ptr(ret_conv, true);
35633 }
35634
35635 uint64_t  __attribute__((export_name("TS_TxCreationKeys_from_channel_static_keys"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint64_t broadcaster_keys, uint64_t countersignatory_keys) {
35636         LDKPublicKey per_commitment_point_ref;
35637         CHECK(per_commitment_point->arr_len == 33);
35638         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35639         LDKChannelPublicKeys broadcaster_keys_conv;
35640         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
35641         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
35642         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
35643         broadcaster_keys_conv.is_owned = false;
35644         LDKChannelPublicKeys countersignatory_keys_conv;
35645         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
35646         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
35647         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
35648         countersignatory_keys_conv.is_owned = false;
35649         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
35650         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
35651         return tag_ptr(ret_conv, true);
35652 }
35653
35654 int8_tArray  __attribute__((export_name("TS_get_revokeable_redeemscript"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
35655         LDKPublicKey revocation_key_ref;
35656         CHECK(revocation_key->arr_len == 33);
35657         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
35658         LDKPublicKey broadcaster_delayed_payment_key_ref;
35659         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
35660         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
35661         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
35662         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35663         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35664         CVec_u8Z_free(ret_var);
35665         return ret_arr;
35666 }
35667
35668 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint64_t this_obj) {
35669         LDKHTLCOutputInCommitment this_obj_conv;
35670         this_obj_conv.inner = untag_ptr(this_obj);
35671         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35673         HTLCOutputInCommitment_free(this_obj_conv);
35674 }
35675
35676 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint64_t this_ptr) {
35677         LDKHTLCOutputInCommitment this_ptr_conv;
35678         this_ptr_conv.inner = untag_ptr(this_ptr);
35679         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35681         this_ptr_conv.is_owned = false;
35682         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
35683         return ret_conv;
35684 }
35685
35686 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint64_t this_ptr, jboolean val) {
35687         LDKHTLCOutputInCommitment this_ptr_conv;
35688         this_ptr_conv.inner = untag_ptr(this_ptr);
35689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35691         this_ptr_conv.is_owned = false;
35692         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
35693 }
35694
35695 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint64_t this_ptr) {
35696         LDKHTLCOutputInCommitment this_ptr_conv;
35697         this_ptr_conv.inner = untag_ptr(this_ptr);
35698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35700         this_ptr_conv.is_owned = false;
35701         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
35702         return ret_conv;
35703 }
35704
35705 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint64_t this_ptr, int64_t val) {
35706         LDKHTLCOutputInCommitment this_ptr_conv;
35707         this_ptr_conv.inner = untag_ptr(this_ptr);
35708         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35710         this_ptr_conv.is_owned = false;
35711         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
35712 }
35713
35714 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint64_t this_ptr) {
35715         LDKHTLCOutputInCommitment this_ptr_conv;
35716         this_ptr_conv.inner = untag_ptr(this_ptr);
35717         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35719         this_ptr_conv.is_owned = false;
35720         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
35721         return ret_conv;
35722 }
35723
35724 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint64_t this_ptr, int32_t val) {
35725         LDKHTLCOutputInCommitment this_ptr_conv;
35726         this_ptr_conv.inner = untag_ptr(this_ptr);
35727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35729         this_ptr_conv.is_owned = false;
35730         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
35731 }
35732
35733 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint64_t this_ptr) {
35734         LDKHTLCOutputInCommitment this_ptr_conv;
35735         this_ptr_conv.inner = untag_ptr(this_ptr);
35736         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35738         this_ptr_conv.is_owned = false;
35739         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35740         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
35741         return ret_arr;
35742 }
35743
35744 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint64_t this_ptr, int8_tArray val) {
35745         LDKHTLCOutputInCommitment this_ptr_conv;
35746         this_ptr_conv.inner = untag_ptr(this_ptr);
35747         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35749         this_ptr_conv.is_owned = false;
35750         LDKThirtyTwoBytes val_ref;
35751         CHECK(val->arr_len == 32);
35752         memcpy(val_ref.data, val->elems, 32); FREE(val);
35753         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
35754 }
35755
35756 uint64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint64_t this_ptr) {
35757         LDKHTLCOutputInCommitment this_ptr_conv;
35758         this_ptr_conv.inner = untag_ptr(this_ptr);
35759         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35761         this_ptr_conv.is_owned = false;
35762         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
35763         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
35764         uint64_t ret_ref = tag_ptr(ret_copy, true);
35765         return ret_ref;
35766 }
35767
35768 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint64_t this_ptr, uint64_t val) {
35769         LDKHTLCOutputInCommitment this_ptr_conv;
35770         this_ptr_conv.inner = untag_ptr(this_ptr);
35771         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35773         this_ptr_conv.is_owned = false;
35774         void* val_ptr = untag_ptr(val);
35775         CHECK_ACCESS(val_ptr);
35776         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
35777         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
35778         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
35779 }
35780
35781 uint64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_new"))) TS_HTLCOutputInCommitment_new(jboolean offered_arg, int64_t amount_msat_arg, int32_t cltv_expiry_arg, int8_tArray payment_hash_arg, uint64_t transaction_output_index_arg) {
35782         LDKThirtyTwoBytes payment_hash_arg_ref;
35783         CHECK(payment_hash_arg->arr_len == 32);
35784         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
35785         void* transaction_output_index_arg_ptr = untag_ptr(transaction_output_index_arg);
35786         CHECK_ACCESS(transaction_output_index_arg_ptr);
35787         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
35788         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(transaction_output_index_arg));
35789         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
35790         uint64_t ret_ref = 0;
35791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35792         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35793         return ret_ref;
35794 }
35795
35796 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
35797         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
35798         uint64_t ret_ref = 0;
35799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35800         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35801         return ret_ref;
35802 }
35803 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint64_t arg) {
35804         LDKHTLCOutputInCommitment arg_conv;
35805         arg_conv.inner = untag_ptr(arg);
35806         arg_conv.is_owned = ptr_is_owned(arg);
35807         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35808         arg_conv.is_owned = false;
35809         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
35810         return ret_conv;
35811 }
35812
35813 uint64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint64_t orig) {
35814         LDKHTLCOutputInCommitment orig_conv;
35815         orig_conv.inner = untag_ptr(orig);
35816         orig_conv.is_owned = ptr_is_owned(orig);
35817         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35818         orig_conv.is_owned = false;
35819         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
35820         uint64_t ret_ref = 0;
35821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35822         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35823         return ret_ref;
35824 }
35825
35826 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint64_t obj) {
35827         LDKHTLCOutputInCommitment obj_conv;
35828         obj_conv.inner = untag_ptr(obj);
35829         obj_conv.is_owned = ptr_is_owned(obj);
35830         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35831         obj_conv.is_owned = false;
35832         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
35833         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35834         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35835         CVec_u8Z_free(ret_var);
35836         return ret_arr;
35837 }
35838
35839 uint64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
35840         LDKu8slice ser_ref;
35841         ser_ref.datalen = ser->arr_len;
35842         ser_ref.data = ser->elems;
35843         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
35844         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
35845         FREE(ser);
35846         return tag_ptr(ret_conv, true);
35847 }
35848
35849 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint64_t htlc, jboolean opt_anchors, uint64_t keys) {
35850         LDKHTLCOutputInCommitment htlc_conv;
35851         htlc_conv.inner = untag_ptr(htlc);
35852         htlc_conv.is_owned = ptr_is_owned(htlc);
35853         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
35854         htlc_conv.is_owned = false;
35855         LDKTxCreationKeys keys_conv;
35856         keys_conv.inner = untag_ptr(keys);
35857         keys_conv.is_owned = ptr_is_owned(keys);
35858         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
35859         keys_conv.is_owned = false;
35860         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
35861         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35862         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35863         CVec_u8Z_free(ret_var);
35864         return ret_arr;
35865 }
35866
35867 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
35868         LDKPublicKey broadcaster_ref;
35869         CHECK(broadcaster->arr_len == 33);
35870         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
35871         LDKPublicKey countersignatory_ref;
35872         CHECK(countersignatory->arr_len == 33);
35873         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
35874         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
35875         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35876         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35877         CVec_u8Z_free(ret_var);
35878         return ret_arr;
35879 }
35880
35881 int8_tArray  __attribute__((export_name("TS_build_htlc_transaction"))) TS_build_htlc_transaction(int8_tArray commitment_txid, int32_t feerate_per_kw, int16_t contest_delay, uint64_t htlc, jboolean opt_anchors, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
35882         unsigned char commitment_txid_arr[32];
35883         CHECK(commitment_txid->arr_len == 32);
35884         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
35885         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
35886         LDKHTLCOutputInCommitment htlc_conv;
35887         htlc_conv.inner = untag_ptr(htlc);
35888         htlc_conv.is_owned = ptr_is_owned(htlc);
35889         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
35890         htlc_conv.is_owned = false;
35891         LDKPublicKey broadcaster_delayed_payment_key_ref;
35892         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
35893         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
35894         LDKPublicKey revocation_key_ref;
35895         CHECK(revocation_key->arr_len == 33);
35896         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
35897         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, opt_anchors, broadcaster_delayed_payment_key_ref, revocation_key_ref);
35898         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35899         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35900         Transaction_free(ret_var);
35901         return ret_arr;
35902 }
35903
35904 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
35905         LDKPublicKey funding_pubkey_ref;
35906         CHECK(funding_pubkey->arr_len == 33);
35907         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
35908         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
35909         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35910         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35911         CVec_u8Z_free(ret_var);
35912         return ret_arr;
35913 }
35914
35915 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint64_t this_obj) {
35916         LDKChannelTransactionParameters this_obj_conv;
35917         this_obj_conv.inner = untag_ptr(this_obj);
35918         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35920         ChannelTransactionParameters_free(this_obj_conv);
35921 }
35922
35923 uint64_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint64_t this_ptr) {
35924         LDKChannelTransactionParameters this_ptr_conv;
35925         this_ptr_conv.inner = untag_ptr(this_ptr);
35926         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35928         this_ptr_conv.is_owned = false;
35929         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
35930         uint64_t ret_ref = 0;
35931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35932         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35933         return ret_ref;
35934 }
35935
35936 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint64_t this_ptr, uint64_t val) {
35937         LDKChannelTransactionParameters this_ptr_conv;
35938         this_ptr_conv.inner = untag_ptr(this_ptr);
35939         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35941         this_ptr_conv.is_owned = false;
35942         LDKChannelPublicKeys val_conv;
35943         val_conv.inner = untag_ptr(val);
35944         val_conv.is_owned = ptr_is_owned(val);
35945         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35946         val_conv = ChannelPublicKeys_clone(&val_conv);
35947         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
35948 }
35949
35950 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint64_t this_ptr) {
35951         LDKChannelTransactionParameters this_ptr_conv;
35952         this_ptr_conv.inner = untag_ptr(this_ptr);
35953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35955         this_ptr_conv.is_owned = false;
35956         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
35957         return ret_conv;
35958 }
35959
35960 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint64_t this_ptr, int16_t val) {
35961         LDKChannelTransactionParameters this_ptr_conv;
35962         this_ptr_conv.inner = untag_ptr(this_ptr);
35963         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35965         this_ptr_conv.is_owned = false;
35966         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
35967 }
35968
35969 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint64_t this_ptr) {
35970         LDKChannelTransactionParameters this_ptr_conv;
35971         this_ptr_conv.inner = untag_ptr(this_ptr);
35972         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35974         this_ptr_conv.is_owned = false;
35975         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
35976         return ret_conv;
35977 }
35978
35979 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint64_t this_ptr, jboolean val) {
35980         LDKChannelTransactionParameters this_ptr_conv;
35981         this_ptr_conv.inner = untag_ptr(this_ptr);
35982         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35984         this_ptr_conv.is_owned = false;
35985         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
35986 }
35987
35988 uint64_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint64_t this_ptr) {
35989         LDKChannelTransactionParameters this_ptr_conv;
35990         this_ptr_conv.inner = untag_ptr(this_ptr);
35991         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35993         this_ptr_conv.is_owned = false;
35994         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
35995         uint64_t ret_ref = 0;
35996         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35997         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35998         return ret_ref;
35999 }
36000
36001 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint64_t this_ptr, uint64_t val) {
36002         LDKChannelTransactionParameters this_ptr_conv;
36003         this_ptr_conv.inner = untag_ptr(this_ptr);
36004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36006         this_ptr_conv.is_owned = false;
36007         LDKCounterpartyChannelTransactionParameters val_conv;
36008         val_conv.inner = untag_ptr(val);
36009         val_conv.is_owned = ptr_is_owned(val);
36010         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36011         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
36012         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
36013 }
36014
36015 uint64_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint64_t this_ptr) {
36016         LDKChannelTransactionParameters this_ptr_conv;
36017         this_ptr_conv.inner = untag_ptr(this_ptr);
36018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36020         this_ptr_conv.is_owned = false;
36021         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
36022         uint64_t ret_ref = 0;
36023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36024         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36025         return ret_ref;
36026 }
36027
36028 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint64_t this_ptr, uint64_t val) {
36029         LDKChannelTransactionParameters this_ptr_conv;
36030         this_ptr_conv.inner = untag_ptr(this_ptr);
36031         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36033         this_ptr_conv.is_owned = false;
36034         LDKOutPoint val_conv;
36035         val_conv.inner = untag_ptr(val);
36036         val_conv.is_owned = ptr_is_owned(val);
36037         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36038         val_conv = OutPoint_clone(&val_conv);
36039         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
36040 }
36041
36042 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint64_t this_ptr) {
36043         LDKChannelTransactionParameters this_ptr_conv;
36044         this_ptr_conv.inner = untag_ptr(this_ptr);
36045         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36047         this_ptr_conv.is_owned = false;
36048         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
36049         return ret_conv;
36050 }
36051
36052 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint64_t this_ptr, uint32_t val) {
36053         LDKChannelTransactionParameters this_ptr_conv;
36054         this_ptr_conv.inner = untag_ptr(this_ptr);
36055         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36057         this_ptr_conv.is_owned = false;
36058         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
36059         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
36060 }
36061
36062 uint64_t  __attribute__((export_name("TS_ChannelTransactionParameters_new"))) TS_ChannelTransactionParameters_new(uint64_t holder_pubkeys_arg, int16_t holder_selected_contest_delay_arg, jboolean is_outbound_from_holder_arg, uint64_t counterparty_parameters_arg, uint64_t funding_outpoint_arg, uint32_t opt_anchors_arg) {
36063         LDKChannelPublicKeys holder_pubkeys_arg_conv;
36064         holder_pubkeys_arg_conv.inner = untag_ptr(holder_pubkeys_arg);
36065         holder_pubkeys_arg_conv.is_owned = ptr_is_owned(holder_pubkeys_arg);
36066         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
36067         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
36068         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
36069         counterparty_parameters_arg_conv.inner = untag_ptr(counterparty_parameters_arg);
36070         counterparty_parameters_arg_conv.is_owned = ptr_is_owned(counterparty_parameters_arg);
36071         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
36072         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
36073         LDKOutPoint funding_outpoint_arg_conv;
36074         funding_outpoint_arg_conv.inner = untag_ptr(funding_outpoint_arg);
36075         funding_outpoint_arg_conv.is_owned = ptr_is_owned(funding_outpoint_arg);
36076         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
36077         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
36078         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
36079         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, opt_anchors_arg_conv);
36080         uint64_t ret_ref = 0;
36081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36082         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36083         return ret_ref;
36084 }
36085
36086 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
36087         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
36088         uint64_t ret_ref = 0;
36089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36090         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36091         return ret_ref;
36092 }
36093 int64_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint64_t arg) {
36094         LDKChannelTransactionParameters arg_conv;
36095         arg_conv.inner = untag_ptr(arg);
36096         arg_conv.is_owned = ptr_is_owned(arg);
36097         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36098         arg_conv.is_owned = false;
36099         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
36100         return ret_conv;
36101 }
36102
36103 uint64_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint64_t orig) {
36104         LDKChannelTransactionParameters orig_conv;
36105         orig_conv.inner = untag_ptr(orig);
36106         orig_conv.is_owned = ptr_is_owned(orig);
36107         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36108         orig_conv.is_owned = false;
36109         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
36110         uint64_t ret_ref = 0;
36111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36112         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36113         return ret_ref;
36114 }
36115
36116 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint64_t this_obj) {
36117         LDKCounterpartyChannelTransactionParameters this_obj_conv;
36118         this_obj_conv.inner = untag_ptr(this_obj);
36119         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36121         CounterpartyChannelTransactionParameters_free(this_obj_conv);
36122 }
36123
36124 uint64_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint64_t this_ptr) {
36125         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36126         this_ptr_conv.inner = untag_ptr(this_ptr);
36127         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36129         this_ptr_conv.is_owned = false;
36130         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
36131         uint64_t ret_ref = 0;
36132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36133         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36134         return ret_ref;
36135 }
36136
36137 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint64_t this_ptr, uint64_t val) {
36138         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36139         this_ptr_conv.inner = untag_ptr(this_ptr);
36140         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36142         this_ptr_conv.is_owned = false;
36143         LDKChannelPublicKeys val_conv;
36144         val_conv.inner = untag_ptr(val);
36145         val_conv.is_owned = ptr_is_owned(val);
36146         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36147         val_conv = ChannelPublicKeys_clone(&val_conv);
36148         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
36149 }
36150
36151 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint64_t this_ptr) {
36152         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36153         this_ptr_conv.inner = untag_ptr(this_ptr);
36154         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36156         this_ptr_conv.is_owned = false;
36157         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
36158         return ret_conv;
36159 }
36160
36161 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint64_t this_ptr, int16_t val) {
36162         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36163         this_ptr_conv.inner = untag_ptr(this_ptr);
36164         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36166         this_ptr_conv.is_owned = false;
36167         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
36168 }
36169
36170 uint64_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint64_t pubkeys_arg, int16_t selected_contest_delay_arg) {
36171         LDKChannelPublicKeys pubkeys_arg_conv;
36172         pubkeys_arg_conv.inner = untag_ptr(pubkeys_arg);
36173         pubkeys_arg_conv.is_owned = ptr_is_owned(pubkeys_arg);
36174         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
36175         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
36176         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
36177         uint64_t ret_ref = 0;
36178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36179         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36180         return ret_ref;
36181 }
36182
36183 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
36184         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
36185         uint64_t ret_ref = 0;
36186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36187         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36188         return ret_ref;
36189 }
36190 int64_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint64_t arg) {
36191         LDKCounterpartyChannelTransactionParameters arg_conv;
36192         arg_conv.inner = untag_ptr(arg);
36193         arg_conv.is_owned = ptr_is_owned(arg);
36194         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36195         arg_conv.is_owned = false;
36196         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
36197         return ret_conv;
36198 }
36199
36200 uint64_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint64_t orig) {
36201         LDKCounterpartyChannelTransactionParameters orig_conv;
36202         orig_conv.inner = untag_ptr(orig);
36203         orig_conv.is_owned = ptr_is_owned(orig);
36204         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36205         orig_conv.is_owned = false;
36206         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
36207         uint64_t ret_ref = 0;
36208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36209         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36210         return ret_ref;
36211 }
36212
36213 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint64_t this_arg) {
36214         LDKChannelTransactionParameters this_arg_conv;
36215         this_arg_conv.inner = untag_ptr(this_arg);
36216         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36218         this_arg_conv.is_owned = false;
36219         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
36220         return ret_conv;
36221 }
36222
36223 uint64_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint64_t this_arg) {
36224         LDKChannelTransactionParameters this_arg_conv;
36225         this_arg_conv.inner = untag_ptr(this_arg);
36226         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36228         this_arg_conv.is_owned = false;
36229         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
36230         uint64_t ret_ref = 0;
36231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36232         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36233         return ret_ref;
36234 }
36235
36236 uint64_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint64_t this_arg) {
36237         LDKChannelTransactionParameters this_arg_conv;
36238         this_arg_conv.inner = untag_ptr(this_arg);
36239         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36241         this_arg_conv.is_owned = false;
36242         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
36243         uint64_t ret_ref = 0;
36244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36245         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36246         return ret_ref;
36247 }
36248
36249 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint64_t obj) {
36250         LDKCounterpartyChannelTransactionParameters obj_conv;
36251         obj_conv.inner = untag_ptr(obj);
36252         obj_conv.is_owned = ptr_is_owned(obj);
36253         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36254         obj_conv.is_owned = false;
36255         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
36256         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36257         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36258         CVec_u8Z_free(ret_var);
36259         return ret_arr;
36260 }
36261
36262 uint64_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
36263         LDKu8slice ser_ref;
36264         ser_ref.datalen = ser->arr_len;
36265         ser_ref.data = ser->elems;
36266         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
36267         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
36268         FREE(ser);
36269         return tag_ptr(ret_conv, true);
36270 }
36271
36272 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint64_t obj) {
36273         LDKChannelTransactionParameters obj_conv;
36274         obj_conv.inner = untag_ptr(obj);
36275         obj_conv.is_owned = ptr_is_owned(obj);
36276         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36277         obj_conv.is_owned = false;
36278         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
36279         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36280         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36281         CVec_u8Z_free(ret_var);
36282         return ret_arr;
36283 }
36284
36285 uint64_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
36286         LDKu8slice ser_ref;
36287         ser_ref.datalen = ser->arr_len;
36288         ser_ref.data = ser->elems;
36289         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
36290         *ret_conv = ChannelTransactionParameters_read(ser_ref);
36291         FREE(ser);
36292         return tag_ptr(ret_conv, true);
36293 }
36294
36295 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint64_t this_obj) {
36296         LDKDirectedChannelTransactionParameters this_obj_conv;
36297         this_obj_conv.inner = untag_ptr(this_obj);
36298         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36300         DirectedChannelTransactionParameters_free(this_obj_conv);
36301 }
36302
36303 uint64_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint64_t this_arg) {
36304         LDKDirectedChannelTransactionParameters this_arg_conv;
36305         this_arg_conv.inner = untag_ptr(this_arg);
36306         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36308         this_arg_conv.is_owned = false;
36309         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
36310         uint64_t ret_ref = 0;
36311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36312         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36313         return ret_ref;
36314 }
36315
36316 uint64_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint64_t this_arg) {
36317         LDKDirectedChannelTransactionParameters this_arg_conv;
36318         this_arg_conv.inner = untag_ptr(this_arg);
36319         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36321         this_arg_conv.is_owned = false;
36322         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
36323         uint64_t ret_ref = 0;
36324         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36325         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36326         return ret_ref;
36327 }
36328
36329 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint64_t this_arg) {
36330         LDKDirectedChannelTransactionParameters this_arg_conv;
36331         this_arg_conv.inner = untag_ptr(this_arg);
36332         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36334         this_arg_conv.is_owned = false;
36335         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
36336         return ret_conv;
36337 }
36338
36339 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint64_t this_arg) {
36340         LDKDirectedChannelTransactionParameters this_arg_conv;
36341         this_arg_conv.inner = untag_ptr(this_arg);
36342         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36344         this_arg_conv.is_owned = false;
36345         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
36346         return ret_conv;
36347 }
36348
36349 uint64_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint64_t this_arg) {
36350         LDKDirectedChannelTransactionParameters this_arg_conv;
36351         this_arg_conv.inner = untag_ptr(this_arg);
36352         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36354         this_arg_conv.is_owned = false;
36355         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
36356         uint64_t ret_ref = 0;
36357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36358         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36359         return ret_ref;
36360 }
36361
36362 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint64_t this_arg) {
36363         LDKDirectedChannelTransactionParameters this_arg_conv;
36364         this_arg_conv.inner = untag_ptr(this_arg);
36365         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36367         this_arg_conv.is_owned = false;
36368         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
36369         return ret_conv;
36370 }
36371
36372 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint64_t this_obj) {
36373         LDKHolderCommitmentTransaction this_obj_conv;
36374         this_obj_conv.inner = untag_ptr(this_obj);
36375         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36377         HolderCommitmentTransaction_free(this_obj_conv);
36378 }
36379
36380 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint64_t this_ptr) {
36381         LDKHolderCommitmentTransaction this_ptr_conv;
36382         this_ptr_conv.inner = untag_ptr(this_ptr);
36383         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36385         this_ptr_conv.is_owned = false;
36386         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
36387         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
36388         return ret_arr;
36389 }
36390
36391 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint64_t this_ptr, int8_tArray val) {
36392         LDKHolderCommitmentTransaction this_ptr_conv;
36393         this_ptr_conv.inner = untag_ptr(this_ptr);
36394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36396         this_ptr_conv.is_owned = false;
36397         LDKSignature val_ref;
36398         CHECK(val->arr_len == 64);
36399         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
36400         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
36401 }
36402
36403 ptrArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_get_counterparty_htlc_sigs(uint64_t this_ptr) {
36404         LDKHolderCommitmentTransaction this_ptr_conv;
36405         this_ptr_conv.inner = untag_ptr(this_ptr);
36406         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36408         this_ptr_conv.is_owned = false;
36409         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
36410         ptrArray ret_arr = NULL;
36411         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
36412         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
36413         for (size_t m = 0; m < ret_var.datalen; m++) {
36414                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
36415                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
36416                 ret_arr_ptr[m] = ret_conv_12_arr;
36417         }
36418         
36419         FREE(ret_var.data);
36420         return ret_arr;
36421 }
36422
36423 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint64_t this_ptr, ptrArray val) {
36424         LDKHolderCommitmentTransaction this_ptr_conv;
36425         this_ptr_conv.inner = untag_ptr(this_ptr);
36426         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36428         this_ptr_conv.is_owned = false;
36429         LDKCVec_SignatureZ val_constr;
36430         val_constr.datalen = val->arr_len;
36431         if (val_constr.datalen > 0)
36432                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
36433         else
36434                 val_constr.data = NULL;
36435         int8_tArray* val_vals = (void*) val->elems;
36436         for (size_t m = 0; m < val_constr.datalen; m++) {
36437                 int8_tArray val_conv_12 = val_vals[m];
36438                 LDKSignature val_conv_12_ref;
36439                 CHECK(val_conv_12->arr_len == 64);
36440                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
36441                 val_constr.data[m] = val_conv_12_ref;
36442         }
36443         FREE(val);
36444         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
36445 }
36446
36447 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
36448         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
36449         uint64_t ret_ref = 0;
36450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36451         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36452         return ret_ref;
36453 }
36454 int64_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint64_t arg) {
36455         LDKHolderCommitmentTransaction arg_conv;
36456         arg_conv.inner = untag_ptr(arg);
36457         arg_conv.is_owned = ptr_is_owned(arg);
36458         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36459         arg_conv.is_owned = false;
36460         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
36461         return ret_conv;
36462 }
36463
36464 uint64_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint64_t orig) {
36465         LDKHolderCommitmentTransaction orig_conv;
36466         orig_conv.inner = untag_ptr(orig);
36467         orig_conv.is_owned = ptr_is_owned(orig);
36468         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36469         orig_conv.is_owned = false;
36470         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
36471         uint64_t ret_ref = 0;
36472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36473         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36474         return ret_ref;
36475 }
36476
36477 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint64_t obj) {
36478         LDKHolderCommitmentTransaction obj_conv;
36479         obj_conv.inner = untag_ptr(obj);
36480         obj_conv.is_owned = ptr_is_owned(obj);
36481         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36482         obj_conv.is_owned = false;
36483         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
36484         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36485         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36486         CVec_u8Z_free(ret_var);
36487         return ret_arr;
36488 }
36489
36490 uint64_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
36491         LDKu8slice ser_ref;
36492         ser_ref.datalen = ser->arr_len;
36493         ser_ref.data = ser->elems;
36494         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
36495         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
36496         FREE(ser);
36497         return tag_ptr(ret_conv, true);
36498 }
36499
36500 uint64_t  __attribute__((export_name("TS_HolderCommitmentTransaction_new"))) TS_HolderCommitmentTransaction_new(uint64_t commitment_tx, int8_tArray counterparty_sig, ptrArray counterparty_htlc_sigs, int8_tArray holder_funding_key, int8_tArray counterparty_funding_key) {
36501         LDKCommitmentTransaction commitment_tx_conv;
36502         commitment_tx_conv.inner = untag_ptr(commitment_tx);
36503         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
36504         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
36505         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
36506         LDKSignature counterparty_sig_ref;
36507         CHECK(counterparty_sig->arr_len == 64);
36508         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
36509         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
36510         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
36511         if (counterparty_htlc_sigs_constr.datalen > 0)
36512                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
36513         else
36514                 counterparty_htlc_sigs_constr.data = NULL;
36515         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems;
36516         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
36517                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
36518                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
36519                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
36520                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
36521                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
36522         }
36523         FREE(counterparty_htlc_sigs);
36524         LDKPublicKey holder_funding_key_ref;
36525         CHECK(holder_funding_key->arr_len == 33);
36526         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
36527         LDKPublicKey counterparty_funding_key_ref;
36528         CHECK(counterparty_funding_key->arr_len == 33);
36529         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
36530         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
36531         uint64_t ret_ref = 0;
36532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36533         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36534         return ret_ref;
36535 }
36536
36537 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint64_t this_obj) {
36538         LDKBuiltCommitmentTransaction this_obj_conv;
36539         this_obj_conv.inner = untag_ptr(this_obj);
36540         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36542         BuiltCommitmentTransaction_free(this_obj_conv);
36543 }
36544
36545 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint64_t this_ptr) {
36546         LDKBuiltCommitmentTransaction this_ptr_conv;
36547         this_ptr_conv.inner = untag_ptr(this_ptr);
36548         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36550         this_ptr_conv.is_owned = false;
36551         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
36552         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36553         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36554         Transaction_free(ret_var);
36555         return ret_arr;
36556 }
36557
36558 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint64_t this_ptr, int8_tArray val) {
36559         LDKBuiltCommitmentTransaction this_ptr_conv;
36560         this_ptr_conv.inner = untag_ptr(this_ptr);
36561         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36563         this_ptr_conv.is_owned = false;
36564         LDKTransaction val_ref;
36565         val_ref.datalen = val->arr_len;
36566         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
36567         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
36568         val_ref.data_is_owned = true;
36569         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
36570 }
36571
36572 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint64_t this_ptr) {
36573         LDKBuiltCommitmentTransaction this_ptr_conv;
36574         this_ptr_conv.inner = untag_ptr(this_ptr);
36575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36577         this_ptr_conv.is_owned = false;
36578         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36579         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
36580         return ret_arr;
36581 }
36582
36583 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint64_t this_ptr, int8_tArray val) {
36584         LDKBuiltCommitmentTransaction this_ptr_conv;
36585         this_ptr_conv.inner = untag_ptr(this_ptr);
36586         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36588         this_ptr_conv.is_owned = false;
36589         LDKThirtyTwoBytes val_ref;
36590         CHECK(val->arr_len == 32);
36591         memcpy(val_ref.data, val->elems, 32); FREE(val);
36592         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
36593 }
36594
36595 uint64_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
36596         LDKTransaction transaction_arg_ref;
36597         transaction_arg_ref.datalen = transaction_arg->arr_len;
36598         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
36599         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
36600         transaction_arg_ref.data_is_owned = true;
36601         LDKThirtyTwoBytes txid_arg_ref;
36602         CHECK(txid_arg->arr_len == 32);
36603         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
36604         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
36605         uint64_t ret_ref = 0;
36606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36607         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36608         return ret_ref;
36609 }
36610
36611 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
36612         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
36613         uint64_t ret_ref = 0;
36614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36615         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36616         return ret_ref;
36617 }
36618 int64_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint64_t arg) {
36619         LDKBuiltCommitmentTransaction arg_conv;
36620         arg_conv.inner = untag_ptr(arg);
36621         arg_conv.is_owned = ptr_is_owned(arg);
36622         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36623         arg_conv.is_owned = false;
36624         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
36625         return ret_conv;
36626 }
36627
36628 uint64_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint64_t orig) {
36629         LDKBuiltCommitmentTransaction orig_conv;
36630         orig_conv.inner = untag_ptr(orig);
36631         orig_conv.is_owned = ptr_is_owned(orig);
36632         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36633         orig_conv.is_owned = false;
36634         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
36635         uint64_t ret_ref = 0;
36636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36637         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36638         return ret_ref;
36639 }
36640
36641 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint64_t obj) {
36642         LDKBuiltCommitmentTransaction obj_conv;
36643         obj_conv.inner = untag_ptr(obj);
36644         obj_conv.is_owned = ptr_is_owned(obj);
36645         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36646         obj_conv.is_owned = false;
36647         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
36648         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36649         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36650         CVec_u8Z_free(ret_var);
36651         return ret_arr;
36652 }
36653
36654 uint64_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
36655         LDKu8slice ser_ref;
36656         ser_ref.datalen = ser->arr_len;
36657         ser_ref.data = ser->elems;
36658         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
36659         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
36660         FREE(ser);
36661         return tag_ptr(ret_conv, true);
36662 }
36663
36664 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_sighash_all"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
36665         LDKBuiltCommitmentTransaction this_arg_conv;
36666         this_arg_conv.inner = untag_ptr(this_arg);
36667         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36669         this_arg_conv.is_owned = false;
36670         LDKu8slice funding_redeemscript_ref;
36671         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36672         funding_redeemscript_ref.data = funding_redeemscript->elems;
36673         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36674         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
36675         FREE(funding_redeemscript);
36676         return ret_arr;
36677 }
36678
36679 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_sign"))) TS_BuiltCommitmentTransaction_sign(uint64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
36680         LDKBuiltCommitmentTransaction this_arg_conv;
36681         this_arg_conv.inner = untag_ptr(this_arg);
36682         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36684         this_arg_conv.is_owned = false;
36685         unsigned char funding_key_arr[32];
36686         CHECK(funding_key->arr_len == 32);
36687         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
36688         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
36689         LDKu8slice funding_redeemscript_ref;
36690         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36691         funding_redeemscript_ref.data = funding_redeemscript->elems;
36692         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
36693         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
36694         FREE(funding_redeemscript);
36695         return ret_arr;
36696 }
36697
36698 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint64_t this_obj) {
36699         LDKClosingTransaction this_obj_conv;
36700         this_obj_conv.inner = untag_ptr(this_obj);
36701         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36703         ClosingTransaction_free(this_obj_conv);
36704 }
36705
36706 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
36707         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
36708         uint64_t ret_ref = 0;
36709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36710         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36711         return ret_ref;
36712 }
36713 int64_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint64_t arg) {
36714         LDKClosingTransaction arg_conv;
36715         arg_conv.inner = untag_ptr(arg);
36716         arg_conv.is_owned = ptr_is_owned(arg);
36717         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36718         arg_conv.is_owned = false;
36719         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
36720         return ret_conv;
36721 }
36722
36723 uint64_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint64_t orig) {
36724         LDKClosingTransaction orig_conv;
36725         orig_conv.inner = untag_ptr(orig);
36726         orig_conv.is_owned = ptr_is_owned(orig);
36727         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36728         orig_conv.is_owned = false;
36729         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
36730         uint64_t ret_ref = 0;
36731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36732         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36733         return ret_ref;
36734 }
36735
36736 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint64_t o) {
36737         LDKClosingTransaction o_conv;
36738         o_conv.inner = untag_ptr(o);
36739         o_conv.is_owned = ptr_is_owned(o);
36740         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36741         o_conv.is_owned = false;
36742         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
36743         return ret_conv;
36744 }
36745
36746 uint64_t  __attribute__((export_name("TS_ClosingTransaction_new"))) TS_ClosingTransaction_new(int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, uint64_t funding_outpoint) {
36747         LDKCVec_u8Z to_holder_script_ref;
36748         to_holder_script_ref.datalen = to_holder_script->arr_len;
36749         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
36750         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
36751         LDKCVec_u8Z to_counterparty_script_ref;
36752         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
36753         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
36754         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
36755         LDKOutPoint funding_outpoint_conv;
36756         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
36757         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
36758         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36759         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36760         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
36761         uint64_t ret_ref = 0;
36762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36763         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36764         return ret_ref;
36765 }
36766
36767 uint64_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint64_t this_arg) {
36768         LDKClosingTransaction this_arg_conv;
36769         this_arg_conv.inner = untag_ptr(this_arg);
36770         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36772         this_arg_conv.is_owned = false;
36773         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
36774         uint64_t ret_ref = 0;
36775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36776         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36777         return ret_ref;
36778 }
36779
36780 uint64_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint64_t this_arg, uint64_t funding_outpoint) {
36781         LDKClosingTransaction this_arg_conv;
36782         this_arg_conv.inner = untag_ptr(this_arg);
36783         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36785         this_arg_conv.is_owned = false;
36786         LDKOutPoint funding_outpoint_conv;
36787         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
36788         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
36789         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36790         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36791         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
36792         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
36793         return tag_ptr(ret_conv, true);
36794 }
36795
36796 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint64_t this_arg) {
36797         LDKClosingTransaction this_arg_conv;
36798         this_arg_conv.inner = untag_ptr(this_arg);
36799         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36801         this_arg_conv.is_owned = false;
36802         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
36803         return ret_conv;
36804 }
36805
36806 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint64_t this_arg) {
36807         LDKClosingTransaction this_arg_conv;
36808         this_arg_conv.inner = untag_ptr(this_arg);
36809         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36811         this_arg_conv.is_owned = false;
36812         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
36813         return ret_conv;
36814 }
36815
36816 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint64_t this_arg) {
36817         LDKClosingTransaction this_arg_conv;
36818         this_arg_conv.inner = untag_ptr(this_arg);
36819         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36821         this_arg_conv.is_owned = false;
36822         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
36823         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36824         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36825         return ret_arr;
36826 }
36827
36828 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint64_t this_arg) {
36829         LDKClosingTransaction this_arg_conv;
36830         this_arg_conv.inner = untag_ptr(this_arg);
36831         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36833         this_arg_conv.is_owned = false;
36834         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
36835         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36836         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36837         return ret_arr;
36838 }
36839
36840 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint64_t this_obj) {
36841         LDKTrustedClosingTransaction this_obj_conv;
36842         this_obj_conv.inner = untag_ptr(this_obj);
36843         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36845         TrustedClosingTransaction_free(this_obj_conv);
36846 }
36847
36848 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint64_t this_arg) {
36849         LDKTrustedClosingTransaction this_arg_conv;
36850         this_arg_conv.inner = untag_ptr(this_arg);
36851         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36853         this_arg_conv.is_owned = false;
36854         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
36855         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36856         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36857         Transaction_free(ret_var);
36858         return ret_arr;
36859 }
36860
36861 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_get_sighash_all"))) TS_TrustedClosingTransaction_get_sighash_all(uint64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
36862         LDKTrustedClosingTransaction this_arg_conv;
36863         this_arg_conv.inner = untag_ptr(this_arg);
36864         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36866         this_arg_conv.is_owned = false;
36867         LDKu8slice funding_redeemscript_ref;
36868         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36869         funding_redeemscript_ref.data = funding_redeemscript->elems;
36870         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36871         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
36872         FREE(funding_redeemscript);
36873         return ret_arr;
36874 }
36875
36876 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_sign"))) TS_TrustedClosingTransaction_sign(uint64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
36877         LDKTrustedClosingTransaction this_arg_conv;
36878         this_arg_conv.inner = untag_ptr(this_arg);
36879         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36881         this_arg_conv.is_owned = false;
36882         unsigned char funding_key_arr[32];
36883         CHECK(funding_key->arr_len == 32);
36884         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
36885         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
36886         LDKu8slice funding_redeemscript_ref;
36887         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36888         funding_redeemscript_ref.data = funding_redeemscript->elems;
36889         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
36890         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
36891         FREE(funding_redeemscript);
36892         return ret_arr;
36893 }
36894
36895 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint64_t this_obj) {
36896         LDKCommitmentTransaction this_obj_conv;
36897         this_obj_conv.inner = untag_ptr(this_obj);
36898         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36900         CommitmentTransaction_free(this_obj_conv);
36901 }
36902
36903 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
36904         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
36905         uint64_t ret_ref = 0;
36906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36907         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36908         return ret_ref;
36909 }
36910 int64_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint64_t arg) {
36911         LDKCommitmentTransaction arg_conv;
36912         arg_conv.inner = untag_ptr(arg);
36913         arg_conv.is_owned = ptr_is_owned(arg);
36914         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36915         arg_conv.is_owned = false;
36916         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
36917         return ret_conv;
36918 }
36919
36920 uint64_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint64_t orig) {
36921         LDKCommitmentTransaction orig_conv;
36922         orig_conv.inner = untag_ptr(orig);
36923         orig_conv.is_owned = ptr_is_owned(orig);
36924         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36925         orig_conv.is_owned = false;
36926         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
36927         uint64_t ret_ref = 0;
36928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36929         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36930         return ret_ref;
36931 }
36932
36933 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint64_t obj) {
36934         LDKCommitmentTransaction obj_conv;
36935         obj_conv.inner = untag_ptr(obj);
36936         obj_conv.is_owned = ptr_is_owned(obj);
36937         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36938         obj_conv.is_owned = false;
36939         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
36940         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36941         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36942         CVec_u8Z_free(ret_var);
36943         return ret_arr;
36944 }
36945
36946 uint64_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
36947         LDKu8slice ser_ref;
36948         ser_ref.datalen = ser->arr_len;
36949         ser_ref.data = ser->elems;
36950         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
36951         *ret_conv = CommitmentTransaction_read(ser_ref);
36952         FREE(ser);
36953         return tag_ptr(ret_conv, true);
36954 }
36955
36956 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint64_t this_arg) {
36957         LDKCommitmentTransaction this_arg_conv;
36958         this_arg_conv.inner = untag_ptr(this_arg);
36959         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36961         this_arg_conv.is_owned = false;
36962         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
36963         return ret_conv;
36964 }
36965
36966 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint64_t this_arg) {
36967         LDKCommitmentTransaction this_arg_conv;
36968         this_arg_conv.inner = untag_ptr(this_arg);
36969         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36971         this_arg_conv.is_owned = false;
36972         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
36973         return ret_conv;
36974 }
36975
36976 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint64_t this_arg) {
36977         LDKCommitmentTransaction this_arg_conv;
36978         this_arg_conv.inner = untag_ptr(this_arg);
36979         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36981         this_arg_conv.is_owned = false;
36982         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
36983         return ret_conv;
36984 }
36985
36986 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint64_t this_arg) {
36987         LDKCommitmentTransaction this_arg_conv;
36988         this_arg_conv.inner = untag_ptr(this_arg);
36989         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36991         this_arg_conv.is_owned = false;
36992         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
36993         return ret_conv;
36994 }
36995
36996 uint64_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint64_t this_arg) {
36997         LDKCommitmentTransaction this_arg_conv;
36998         this_arg_conv.inner = untag_ptr(this_arg);
36999         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37001         this_arg_conv.is_owned = false;
37002         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
37003         uint64_t ret_ref = 0;
37004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37005         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37006         return ret_ref;
37007 }
37008
37009 uint64_t  __attribute__((export_name("TS_CommitmentTransaction_verify"))) TS_CommitmentTransaction_verify(uint64_t this_arg, uint64_t channel_parameters, uint64_t broadcaster_keys, uint64_t countersignatory_keys) {
37010         LDKCommitmentTransaction this_arg_conv;
37011         this_arg_conv.inner = untag_ptr(this_arg);
37012         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37014         this_arg_conv.is_owned = false;
37015         LDKDirectedChannelTransactionParameters channel_parameters_conv;
37016         channel_parameters_conv.inner = untag_ptr(channel_parameters);
37017         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
37018         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
37019         channel_parameters_conv.is_owned = false;
37020         LDKChannelPublicKeys broadcaster_keys_conv;
37021         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
37022         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
37023         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
37024         broadcaster_keys_conv.is_owned = false;
37025         LDKChannelPublicKeys countersignatory_keys_conv;
37026         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
37027         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
37028         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
37029         countersignatory_keys_conv.is_owned = false;
37030         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
37031         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
37032         return tag_ptr(ret_conv, true);
37033 }
37034
37035 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint64_t this_obj) {
37036         LDKTrustedCommitmentTransaction this_obj_conv;
37037         this_obj_conv.inner = untag_ptr(this_obj);
37038         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37040         TrustedCommitmentTransaction_free(this_obj_conv);
37041 }
37042
37043 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint64_t this_arg) {
37044         LDKTrustedCommitmentTransaction this_arg_conv;
37045         this_arg_conv.inner = untag_ptr(this_arg);
37046         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37048         this_arg_conv.is_owned = false;
37049         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37050         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
37051         return ret_arr;
37052 }
37053
37054 uint64_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint64_t this_arg) {
37055         LDKTrustedCommitmentTransaction this_arg_conv;
37056         this_arg_conv.inner = untag_ptr(this_arg);
37057         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37059         this_arg_conv.is_owned = false;
37060         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
37061         uint64_t ret_ref = 0;
37062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37063         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37064         return ret_ref;
37065 }
37066
37067 uint64_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint64_t this_arg) {
37068         LDKTrustedCommitmentTransaction this_arg_conv;
37069         this_arg_conv.inner = untag_ptr(this_arg);
37070         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37072         this_arg_conv.is_owned = false;
37073         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
37074         uint64_t ret_ref = 0;
37075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37076         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37077         return ret_ref;
37078 }
37079
37080 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint64_t this_arg) {
37081         LDKTrustedCommitmentTransaction this_arg_conv;
37082         this_arg_conv.inner = untag_ptr(this_arg);
37083         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37085         this_arg_conv.is_owned = false;
37086         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
37087         return ret_conv;
37088 }
37089
37090 uint64_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_get_htlc_sigs"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint64_t this_arg, int8_tArray htlc_base_key, uint64_t channel_parameters) {
37091         LDKTrustedCommitmentTransaction this_arg_conv;
37092         this_arg_conv.inner = untag_ptr(this_arg);
37093         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37095         this_arg_conv.is_owned = false;
37096         unsigned char htlc_base_key_arr[32];
37097         CHECK(htlc_base_key->arr_len == 32);
37098         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
37099         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
37100         LDKDirectedChannelTransactionParameters channel_parameters_conv;
37101         channel_parameters_conv.inner = untag_ptr(channel_parameters);
37102         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
37103         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
37104         channel_parameters_conv.is_owned = false;
37105         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
37106         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
37107         return tag_ptr(ret_conv, true);
37108 }
37109
37110 int64_t  __attribute__((export_name("TS_get_commitment_transaction_number_obscure_factor"))) TS_get_commitment_transaction_number_obscure_factor(int8_tArray broadcaster_payment_basepoint, int8_tArray countersignatory_payment_basepoint, jboolean outbound_from_broadcaster) {
37111         LDKPublicKey broadcaster_payment_basepoint_ref;
37112         CHECK(broadcaster_payment_basepoint->arr_len == 33);
37113         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
37114         LDKPublicKey countersignatory_payment_basepoint_ref;
37115         CHECK(countersignatory_payment_basepoint->arr_len == 33);
37116         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
37117         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
37118         return ret_conv;
37119 }
37120
37121 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint64_t a, uint64_t b) {
37122         LDKInitFeatures a_conv;
37123         a_conv.inner = untag_ptr(a);
37124         a_conv.is_owned = ptr_is_owned(a);
37125         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37126         a_conv.is_owned = false;
37127         LDKInitFeatures b_conv;
37128         b_conv.inner = untag_ptr(b);
37129         b_conv.is_owned = ptr_is_owned(b);
37130         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37131         b_conv.is_owned = false;
37132         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
37133         return ret_conv;
37134 }
37135
37136 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint64_t a, uint64_t b) {
37137         LDKNodeFeatures a_conv;
37138         a_conv.inner = untag_ptr(a);
37139         a_conv.is_owned = ptr_is_owned(a);
37140         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37141         a_conv.is_owned = false;
37142         LDKNodeFeatures b_conv;
37143         b_conv.inner = untag_ptr(b);
37144         b_conv.is_owned = ptr_is_owned(b);
37145         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37146         b_conv.is_owned = false;
37147         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
37148         return ret_conv;
37149 }
37150
37151 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint64_t a, uint64_t b) {
37152         LDKChannelFeatures a_conv;
37153         a_conv.inner = untag_ptr(a);
37154         a_conv.is_owned = ptr_is_owned(a);
37155         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37156         a_conv.is_owned = false;
37157         LDKChannelFeatures b_conv;
37158         b_conv.inner = untag_ptr(b);
37159         b_conv.is_owned = ptr_is_owned(b);
37160         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37161         b_conv.is_owned = false;
37162         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
37163         return ret_conv;
37164 }
37165
37166 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint64_t a, uint64_t b) {
37167         LDKInvoiceFeatures a_conv;
37168         a_conv.inner = untag_ptr(a);
37169         a_conv.is_owned = ptr_is_owned(a);
37170         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37171         a_conv.is_owned = false;
37172         LDKInvoiceFeatures b_conv;
37173         b_conv.inner = untag_ptr(b);
37174         b_conv.is_owned = ptr_is_owned(b);
37175         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37176         b_conv.is_owned = false;
37177         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
37178         return ret_conv;
37179 }
37180
37181 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint64_t a, uint64_t b) {
37182         LDKChannelTypeFeatures a_conv;
37183         a_conv.inner = untag_ptr(a);
37184         a_conv.is_owned = ptr_is_owned(a);
37185         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37186         a_conv.is_owned = false;
37187         LDKChannelTypeFeatures b_conv;
37188         b_conv.inner = untag_ptr(b);
37189         b_conv.is_owned = ptr_is_owned(b);
37190         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37191         b_conv.is_owned = false;
37192         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
37193         return ret_conv;
37194 }
37195
37196 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
37197         LDKInitFeatures ret_var = InitFeatures_clone(arg);
37198         uint64_t ret_ref = 0;
37199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37200         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37201         return ret_ref;
37202 }
37203 int64_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint64_t arg) {
37204         LDKInitFeatures arg_conv;
37205         arg_conv.inner = untag_ptr(arg);
37206         arg_conv.is_owned = ptr_is_owned(arg);
37207         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37208         arg_conv.is_owned = false;
37209         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
37210         return ret_conv;
37211 }
37212
37213 uint64_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint64_t orig) {
37214         LDKInitFeatures orig_conv;
37215         orig_conv.inner = untag_ptr(orig);
37216         orig_conv.is_owned = ptr_is_owned(orig);
37217         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37218         orig_conv.is_owned = false;
37219         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
37220         uint64_t ret_ref = 0;
37221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37222         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37223         return ret_ref;
37224 }
37225
37226 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
37227         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
37228         uint64_t ret_ref = 0;
37229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37230         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37231         return ret_ref;
37232 }
37233 int64_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint64_t arg) {
37234         LDKNodeFeatures arg_conv;
37235         arg_conv.inner = untag_ptr(arg);
37236         arg_conv.is_owned = ptr_is_owned(arg);
37237         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37238         arg_conv.is_owned = false;
37239         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
37240         return ret_conv;
37241 }
37242
37243 uint64_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint64_t orig) {
37244         LDKNodeFeatures orig_conv;
37245         orig_conv.inner = untag_ptr(orig);
37246         orig_conv.is_owned = ptr_is_owned(orig);
37247         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37248         orig_conv.is_owned = false;
37249         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
37250         uint64_t ret_ref = 0;
37251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37252         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37253         return ret_ref;
37254 }
37255
37256 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
37257         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
37258         uint64_t ret_ref = 0;
37259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37260         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37261         return ret_ref;
37262 }
37263 int64_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint64_t arg) {
37264         LDKChannelFeatures arg_conv;
37265         arg_conv.inner = untag_ptr(arg);
37266         arg_conv.is_owned = ptr_is_owned(arg);
37267         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37268         arg_conv.is_owned = false;
37269         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
37270         return ret_conv;
37271 }
37272
37273 uint64_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint64_t orig) {
37274         LDKChannelFeatures orig_conv;
37275         orig_conv.inner = untag_ptr(orig);
37276         orig_conv.is_owned = ptr_is_owned(orig);
37277         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37278         orig_conv.is_owned = false;
37279         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
37280         uint64_t ret_ref = 0;
37281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37282         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37283         return ret_ref;
37284 }
37285
37286 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
37287         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
37288         uint64_t ret_ref = 0;
37289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37290         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37291         return ret_ref;
37292 }
37293 int64_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint64_t arg) {
37294         LDKInvoiceFeatures arg_conv;
37295         arg_conv.inner = untag_ptr(arg);
37296         arg_conv.is_owned = ptr_is_owned(arg);
37297         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37298         arg_conv.is_owned = false;
37299         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
37300         return ret_conv;
37301 }
37302
37303 uint64_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint64_t orig) {
37304         LDKInvoiceFeatures orig_conv;
37305         orig_conv.inner = untag_ptr(orig);
37306         orig_conv.is_owned = ptr_is_owned(orig);
37307         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37308         orig_conv.is_owned = false;
37309         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
37310         uint64_t ret_ref = 0;
37311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37312         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37313         return ret_ref;
37314 }
37315
37316 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
37317         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
37318         uint64_t ret_ref = 0;
37319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37320         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37321         return ret_ref;
37322 }
37323 int64_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint64_t arg) {
37324         LDKChannelTypeFeatures arg_conv;
37325         arg_conv.inner = untag_ptr(arg);
37326         arg_conv.is_owned = ptr_is_owned(arg);
37327         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37328         arg_conv.is_owned = false;
37329         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
37330         return ret_conv;
37331 }
37332
37333 uint64_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint64_t orig) {
37334         LDKChannelTypeFeatures orig_conv;
37335         orig_conv.inner = untag_ptr(orig);
37336         orig_conv.is_owned = ptr_is_owned(orig);
37337         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37338         orig_conv.is_owned = false;
37339         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
37340         uint64_t ret_ref = 0;
37341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37342         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37343         return ret_ref;
37344 }
37345
37346 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint64_t this_obj) {
37347         LDKInitFeatures this_obj_conv;
37348         this_obj_conv.inner = untag_ptr(this_obj);
37349         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37351         InitFeatures_free(this_obj_conv);
37352 }
37353
37354 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint64_t this_obj) {
37355         LDKNodeFeatures this_obj_conv;
37356         this_obj_conv.inner = untag_ptr(this_obj);
37357         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37359         NodeFeatures_free(this_obj_conv);
37360 }
37361
37362 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint64_t this_obj) {
37363         LDKChannelFeatures this_obj_conv;
37364         this_obj_conv.inner = untag_ptr(this_obj);
37365         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37367         ChannelFeatures_free(this_obj_conv);
37368 }
37369
37370 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint64_t this_obj) {
37371         LDKInvoiceFeatures this_obj_conv;
37372         this_obj_conv.inner = untag_ptr(this_obj);
37373         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37375         InvoiceFeatures_free(this_obj_conv);
37376 }
37377
37378 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint64_t this_obj) {
37379         LDKChannelTypeFeatures this_obj_conv;
37380         this_obj_conv.inner = untag_ptr(this_obj);
37381         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37383         ChannelTypeFeatures_free(this_obj_conv);
37384 }
37385
37386 uint64_t  __attribute__((export_name("TS_InitFeatures_known_channel_features"))) TS_InitFeatures_known_channel_features() {
37387         LDKInitFeatures ret_var = InitFeatures_known_channel_features();
37388         uint64_t ret_ref = 0;
37389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37390         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37391         return ret_ref;
37392 }
37393
37394 uint64_t  __attribute__((export_name("TS_NodeFeatures_known_channel_features"))) TS_NodeFeatures_known_channel_features() {
37395         LDKNodeFeatures ret_var = NodeFeatures_known_channel_features();
37396         uint64_t ret_ref = 0;
37397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37398         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37399         return ret_ref;
37400 }
37401
37402 uint64_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
37403         LDKInitFeatures ret_var = InitFeatures_empty();
37404         uint64_t ret_ref = 0;
37405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37406         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37407         return ret_ref;
37408 }
37409
37410 uint64_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
37411         LDKInitFeatures ret_var = InitFeatures_known();
37412         uint64_t ret_ref = 0;
37413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37414         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37415         return ret_ref;
37416 }
37417
37418 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint64_t this_arg) {
37419         LDKInitFeatures this_arg_conv;
37420         this_arg_conv.inner = untag_ptr(this_arg);
37421         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37423         this_arg_conv.is_owned = false;
37424         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
37425         return ret_conv;
37426 }
37427
37428 uint64_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
37429         LDKNodeFeatures ret_var = NodeFeatures_empty();
37430         uint64_t ret_ref = 0;
37431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37432         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37433         return ret_ref;
37434 }
37435
37436 uint64_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
37437         LDKNodeFeatures ret_var = NodeFeatures_known();
37438         uint64_t ret_ref = 0;
37439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37440         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37441         return ret_ref;
37442 }
37443
37444 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint64_t this_arg) {
37445         LDKNodeFeatures this_arg_conv;
37446         this_arg_conv.inner = untag_ptr(this_arg);
37447         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37449         this_arg_conv.is_owned = false;
37450         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
37451         return ret_conv;
37452 }
37453
37454 uint64_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
37455         LDKChannelFeatures ret_var = ChannelFeatures_empty();
37456         uint64_t ret_ref = 0;
37457         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37458         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37459         return ret_ref;
37460 }
37461
37462 uint64_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
37463         LDKChannelFeatures ret_var = ChannelFeatures_known();
37464         uint64_t ret_ref = 0;
37465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37466         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37467         return ret_ref;
37468 }
37469
37470 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint64_t this_arg) {
37471         LDKChannelFeatures this_arg_conv;
37472         this_arg_conv.inner = untag_ptr(this_arg);
37473         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37475         this_arg_conv.is_owned = false;
37476         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
37477         return ret_conv;
37478 }
37479
37480 uint64_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
37481         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
37482         uint64_t ret_ref = 0;
37483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37484         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37485         return ret_ref;
37486 }
37487
37488 uint64_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
37489         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
37490         uint64_t ret_ref = 0;
37491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37492         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37493         return ret_ref;
37494 }
37495
37496 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint64_t this_arg) {
37497         LDKInvoiceFeatures this_arg_conv;
37498         this_arg_conv.inner = untag_ptr(this_arg);
37499         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37501         this_arg_conv.is_owned = false;
37502         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
37503         return ret_conv;
37504 }
37505
37506 uint64_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
37507         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
37508         uint64_t ret_ref = 0;
37509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37510         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37511         return ret_ref;
37512 }
37513
37514 uint64_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
37515         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
37516         uint64_t ret_ref = 0;
37517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37518         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37519         return ret_ref;
37520 }
37521
37522 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint64_t this_arg) {
37523         LDKChannelTypeFeatures this_arg_conv;
37524         this_arg_conv.inner = untag_ptr(this_arg);
37525         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37527         this_arg_conv.is_owned = false;
37528         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
37529         return ret_conv;
37530 }
37531
37532 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint64_t obj) {
37533         LDKInitFeatures obj_conv;
37534         obj_conv.inner = untag_ptr(obj);
37535         obj_conv.is_owned = ptr_is_owned(obj);
37536         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37537         obj_conv.is_owned = false;
37538         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
37539         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37540         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37541         CVec_u8Z_free(ret_var);
37542         return ret_arr;
37543 }
37544
37545 uint64_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
37546         LDKu8slice ser_ref;
37547         ser_ref.datalen = ser->arr_len;
37548         ser_ref.data = ser->elems;
37549         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
37550         *ret_conv = InitFeatures_read(ser_ref);
37551         FREE(ser);
37552         return tag_ptr(ret_conv, true);
37553 }
37554
37555 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint64_t obj) {
37556         LDKChannelFeatures obj_conv;
37557         obj_conv.inner = untag_ptr(obj);
37558         obj_conv.is_owned = ptr_is_owned(obj);
37559         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37560         obj_conv.is_owned = false;
37561         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
37562         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37563         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37564         CVec_u8Z_free(ret_var);
37565         return ret_arr;
37566 }
37567
37568 uint64_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
37569         LDKu8slice ser_ref;
37570         ser_ref.datalen = ser->arr_len;
37571         ser_ref.data = ser->elems;
37572         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
37573         *ret_conv = ChannelFeatures_read(ser_ref);
37574         FREE(ser);
37575         return tag_ptr(ret_conv, true);
37576 }
37577
37578 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint64_t obj) {
37579         LDKNodeFeatures obj_conv;
37580         obj_conv.inner = untag_ptr(obj);
37581         obj_conv.is_owned = ptr_is_owned(obj);
37582         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37583         obj_conv.is_owned = false;
37584         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
37585         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37586         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37587         CVec_u8Z_free(ret_var);
37588         return ret_arr;
37589 }
37590
37591 uint64_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
37592         LDKu8slice ser_ref;
37593         ser_ref.datalen = ser->arr_len;
37594         ser_ref.data = ser->elems;
37595         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
37596         *ret_conv = NodeFeatures_read(ser_ref);
37597         FREE(ser);
37598         return tag_ptr(ret_conv, true);
37599 }
37600
37601 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint64_t obj) {
37602         LDKInvoiceFeatures obj_conv;
37603         obj_conv.inner = untag_ptr(obj);
37604         obj_conv.is_owned = ptr_is_owned(obj);
37605         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37606         obj_conv.is_owned = false;
37607         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
37608         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37609         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37610         CVec_u8Z_free(ret_var);
37611         return ret_arr;
37612 }
37613
37614 uint64_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
37615         LDKu8slice ser_ref;
37616         ser_ref.datalen = ser->arr_len;
37617         ser_ref.data = ser->elems;
37618         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
37619         *ret_conv = InvoiceFeatures_read(ser_ref);
37620         FREE(ser);
37621         return tag_ptr(ret_conv, true);
37622 }
37623
37624 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint64_t obj) {
37625         LDKChannelTypeFeatures obj_conv;
37626         obj_conv.inner = untag_ptr(obj);
37627         obj_conv.is_owned = ptr_is_owned(obj);
37628         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37629         obj_conv.is_owned = false;
37630         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
37631         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37632         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37633         CVec_u8Z_free(ret_var);
37634         return ret_arr;
37635 }
37636
37637 uint64_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
37638         LDKu8slice ser_ref;
37639         ser_ref.datalen = ser->arr_len;
37640         ser_ref.data = ser->elems;
37641         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
37642         *ret_conv = ChannelTypeFeatures_read(ser_ref);
37643         FREE(ser);
37644         return tag_ptr(ret_conv, true);
37645 }
37646
37647 void  __attribute__((export_name("TS_InitFeatures_set_data_loss_protect_optional"))) TS_InitFeatures_set_data_loss_protect_optional(uint64_t this_arg) {
37648         LDKInitFeatures this_arg_conv;
37649         this_arg_conv.inner = untag_ptr(this_arg);
37650         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37652         this_arg_conv.is_owned = false;
37653         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
37654 }
37655
37656 void  __attribute__((export_name("TS_InitFeatures_set_data_loss_protect_required"))) TS_InitFeatures_set_data_loss_protect_required(uint64_t this_arg) {
37657         LDKInitFeatures this_arg_conv;
37658         this_arg_conv.inner = untag_ptr(this_arg);
37659         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37661         this_arg_conv.is_owned = false;
37662         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
37663 }
37664
37665 jboolean  __attribute__((export_name("TS_InitFeatures_supports_data_loss_protect"))) TS_InitFeatures_supports_data_loss_protect(uint64_t this_arg) {
37666         LDKInitFeatures this_arg_conv;
37667         this_arg_conv.inner = untag_ptr(this_arg);
37668         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37670         this_arg_conv.is_owned = false;
37671         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
37672         return ret_conv;
37673 }
37674
37675 void  __attribute__((export_name("TS_NodeFeatures_set_data_loss_protect_optional"))) TS_NodeFeatures_set_data_loss_protect_optional(uint64_t this_arg) {
37676         LDKNodeFeatures this_arg_conv;
37677         this_arg_conv.inner = untag_ptr(this_arg);
37678         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37680         this_arg_conv.is_owned = false;
37681         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
37682 }
37683
37684 void  __attribute__((export_name("TS_NodeFeatures_set_data_loss_protect_required"))) TS_NodeFeatures_set_data_loss_protect_required(uint64_t this_arg) {
37685         LDKNodeFeatures this_arg_conv;
37686         this_arg_conv.inner = untag_ptr(this_arg);
37687         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37689         this_arg_conv.is_owned = false;
37690         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
37691 }
37692
37693 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_data_loss_protect"))) TS_NodeFeatures_supports_data_loss_protect(uint64_t this_arg) {
37694         LDKNodeFeatures this_arg_conv;
37695         this_arg_conv.inner = untag_ptr(this_arg);
37696         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37698         this_arg_conv.is_owned = false;
37699         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
37700         return ret_conv;
37701 }
37702
37703 jboolean  __attribute__((export_name("TS_InitFeatures_requires_data_loss_protect"))) TS_InitFeatures_requires_data_loss_protect(uint64_t this_arg) {
37704         LDKInitFeatures this_arg_conv;
37705         this_arg_conv.inner = untag_ptr(this_arg);
37706         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37708         this_arg_conv.is_owned = false;
37709         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
37710         return ret_conv;
37711 }
37712
37713 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_data_loss_protect"))) TS_NodeFeatures_requires_data_loss_protect(uint64_t this_arg) {
37714         LDKNodeFeatures this_arg_conv;
37715         this_arg_conv.inner = untag_ptr(this_arg);
37716         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37718         this_arg_conv.is_owned = false;
37719         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
37720         return ret_conv;
37721 }
37722
37723 void  __attribute__((export_name("TS_InitFeatures_set_initial_routing_sync_optional"))) TS_InitFeatures_set_initial_routing_sync_optional(uint64_t this_arg) {
37724         LDKInitFeatures this_arg_conv;
37725         this_arg_conv.inner = untag_ptr(this_arg);
37726         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37728         this_arg_conv.is_owned = false;
37729         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
37730 }
37731
37732 void  __attribute__((export_name("TS_InitFeatures_set_initial_routing_sync_required"))) TS_InitFeatures_set_initial_routing_sync_required(uint64_t this_arg) {
37733         LDKInitFeatures this_arg_conv;
37734         this_arg_conv.inner = untag_ptr(this_arg);
37735         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37737         this_arg_conv.is_owned = false;
37738         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
37739 }
37740
37741 jboolean  __attribute__((export_name("TS_InitFeatures_initial_routing_sync"))) TS_InitFeatures_initial_routing_sync(uint64_t this_arg) {
37742         LDKInitFeatures this_arg_conv;
37743         this_arg_conv.inner = untag_ptr(this_arg);
37744         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37746         this_arg_conv.is_owned = false;
37747         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
37748         return ret_conv;
37749 }
37750
37751 void  __attribute__((export_name("TS_InitFeatures_set_upfront_shutdown_script_optional"))) TS_InitFeatures_set_upfront_shutdown_script_optional(uint64_t this_arg) {
37752         LDKInitFeatures this_arg_conv;
37753         this_arg_conv.inner = untag_ptr(this_arg);
37754         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37756         this_arg_conv.is_owned = false;
37757         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
37758 }
37759
37760 void  __attribute__((export_name("TS_InitFeatures_set_upfront_shutdown_script_required"))) TS_InitFeatures_set_upfront_shutdown_script_required(uint64_t this_arg) {
37761         LDKInitFeatures this_arg_conv;
37762         this_arg_conv.inner = untag_ptr(this_arg);
37763         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37765         this_arg_conv.is_owned = false;
37766         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
37767 }
37768
37769 jboolean  __attribute__((export_name("TS_InitFeatures_supports_upfront_shutdown_script"))) TS_InitFeatures_supports_upfront_shutdown_script(uint64_t this_arg) {
37770         LDKInitFeatures this_arg_conv;
37771         this_arg_conv.inner = untag_ptr(this_arg);
37772         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37774         this_arg_conv.is_owned = false;
37775         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
37776         return ret_conv;
37777 }
37778
37779 void  __attribute__((export_name("TS_NodeFeatures_set_upfront_shutdown_script_optional"))) TS_NodeFeatures_set_upfront_shutdown_script_optional(uint64_t this_arg) {
37780         LDKNodeFeatures this_arg_conv;
37781         this_arg_conv.inner = untag_ptr(this_arg);
37782         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37784         this_arg_conv.is_owned = false;
37785         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
37786 }
37787
37788 void  __attribute__((export_name("TS_NodeFeatures_set_upfront_shutdown_script_required"))) TS_NodeFeatures_set_upfront_shutdown_script_required(uint64_t this_arg) {
37789         LDKNodeFeatures this_arg_conv;
37790         this_arg_conv.inner = untag_ptr(this_arg);
37791         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37793         this_arg_conv.is_owned = false;
37794         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
37795 }
37796
37797 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_upfront_shutdown_script"))) TS_NodeFeatures_supports_upfront_shutdown_script(uint64_t this_arg) {
37798         LDKNodeFeatures this_arg_conv;
37799         this_arg_conv.inner = untag_ptr(this_arg);
37800         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37802         this_arg_conv.is_owned = false;
37803         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
37804         return ret_conv;
37805 }
37806
37807 jboolean  __attribute__((export_name("TS_InitFeatures_requires_upfront_shutdown_script"))) TS_InitFeatures_requires_upfront_shutdown_script(uint64_t this_arg) {
37808         LDKInitFeatures this_arg_conv;
37809         this_arg_conv.inner = untag_ptr(this_arg);
37810         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37812         this_arg_conv.is_owned = false;
37813         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
37814         return ret_conv;
37815 }
37816
37817 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_upfront_shutdown_script"))) TS_NodeFeatures_requires_upfront_shutdown_script(uint64_t this_arg) {
37818         LDKNodeFeatures this_arg_conv;
37819         this_arg_conv.inner = untag_ptr(this_arg);
37820         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37822         this_arg_conv.is_owned = false;
37823         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
37824         return ret_conv;
37825 }
37826
37827 void  __attribute__((export_name("TS_InitFeatures_set_gossip_queries_optional"))) TS_InitFeatures_set_gossip_queries_optional(uint64_t this_arg) {
37828         LDKInitFeatures this_arg_conv;
37829         this_arg_conv.inner = untag_ptr(this_arg);
37830         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37832         this_arg_conv.is_owned = false;
37833         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
37834 }
37835
37836 void  __attribute__((export_name("TS_InitFeatures_set_gossip_queries_required"))) TS_InitFeatures_set_gossip_queries_required(uint64_t this_arg) {
37837         LDKInitFeatures this_arg_conv;
37838         this_arg_conv.inner = untag_ptr(this_arg);
37839         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37841         this_arg_conv.is_owned = false;
37842         InitFeatures_set_gossip_queries_required(&this_arg_conv);
37843 }
37844
37845 jboolean  __attribute__((export_name("TS_InitFeatures_supports_gossip_queries"))) TS_InitFeatures_supports_gossip_queries(uint64_t this_arg) {
37846         LDKInitFeatures this_arg_conv;
37847         this_arg_conv.inner = untag_ptr(this_arg);
37848         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37850         this_arg_conv.is_owned = false;
37851         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
37852         return ret_conv;
37853 }
37854
37855 void  __attribute__((export_name("TS_NodeFeatures_set_gossip_queries_optional"))) TS_NodeFeatures_set_gossip_queries_optional(uint64_t this_arg) {
37856         LDKNodeFeatures this_arg_conv;
37857         this_arg_conv.inner = untag_ptr(this_arg);
37858         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37860         this_arg_conv.is_owned = false;
37861         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
37862 }
37863
37864 void  __attribute__((export_name("TS_NodeFeatures_set_gossip_queries_required"))) TS_NodeFeatures_set_gossip_queries_required(uint64_t this_arg) {
37865         LDKNodeFeatures this_arg_conv;
37866         this_arg_conv.inner = untag_ptr(this_arg);
37867         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37869         this_arg_conv.is_owned = false;
37870         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
37871 }
37872
37873 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_gossip_queries"))) TS_NodeFeatures_supports_gossip_queries(uint64_t this_arg) {
37874         LDKNodeFeatures this_arg_conv;
37875         this_arg_conv.inner = untag_ptr(this_arg);
37876         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37878         this_arg_conv.is_owned = false;
37879         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
37880         return ret_conv;
37881 }
37882
37883 jboolean  __attribute__((export_name("TS_InitFeatures_requires_gossip_queries"))) TS_InitFeatures_requires_gossip_queries(uint64_t this_arg) {
37884         LDKInitFeatures this_arg_conv;
37885         this_arg_conv.inner = untag_ptr(this_arg);
37886         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37888         this_arg_conv.is_owned = false;
37889         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
37890         return ret_conv;
37891 }
37892
37893 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_gossip_queries"))) TS_NodeFeatures_requires_gossip_queries(uint64_t this_arg) {
37894         LDKNodeFeatures this_arg_conv;
37895         this_arg_conv.inner = untag_ptr(this_arg);
37896         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37898         this_arg_conv.is_owned = false;
37899         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
37900         return ret_conv;
37901 }
37902
37903 void  __attribute__((export_name("TS_InitFeatures_set_variable_length_onion_optional"))) TS_InitFeatures_set_variable_length_onion_optional(uint64_t this_arg) {
37904         LDKInitFeatures this_arg_conv;
37905         this_arg_conv.inner = untag_ptr(this_arg);
37906         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37908         this_arg_conv.is_owned = false;
37909         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
37910 }
37911
37912 void  __attribute__((export_name("TS_InitFeatures_set_variable_length_onion_required"))) TS_InitFeatures_set_variable_length_onion_required(uint64_t this_arg) {
37913         LDKInitFeatures this_arg_conv;
37914         this_arg_conv.inner = untag_ptr(this_arg);
37915         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37917         this_arg_conv.is_owned = false;
37918         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
37919 }
37920
37921 jboolean  __attribute__((export_name("TS_InitFeatures_supports_variable_length_onion"))) TS_InitFeatures_supports_variable_length_onion(uint64_t this_arg) {
37922         LDKInitFeatures this_arg_conv;
37923         this_arg_conv.inner = untag_ptr(this_arg);
37924         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37926         this_arg_conv.is_owned = false;
37927         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
37928         return ret_conv;
37929 }
37930
37931 void  __attribute__((export_name("TS_NodeFeatures_set_variable_length_onion_optional"))) TS_NodeFeatures_set_variable_length_onion_optional(uint64_t this_arg) {
37932         LDKNodeFeatures this_arg_conv;
37933         this_arg_conv.inner = untag_ptr(this_arg);
37934         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37936         this_arg_conv.is_owned = false;
37937         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
37938 }
37939
37940 void  __attribute__((export_name("TS_NodeFeatures_set_variable_length_onion_required"))) TS_NodeFeatures_set_variable_length_onion_required(uint64_t this_arg) {
37941         LDKNodeFeatures this_arg_conv;
37942         this_arg_conv.inner = untag_ptr(this_arg);
37943         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37945         this_arg_conv.is_owned = false;
37946         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
37947 }
37948
37949 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_variable_length_onion"))) TS_NodeFeatures_supports_variable_length_onion(uint64_t this_arg) {
37950         LDKNodeFeatures this_arg_conv;
37951         this_arg_conv.inner = untag_ptr(this_arg);
37952         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37954         this_arg_conv.is_owned = false;
37955         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
37956         return ret_conv;
37957 }
37958
37959 void  __attribute__((export_name("TS_InvoiceFeatures_set_variable_length_onion_optional"))) TS_InvoiceFeatures_set_variable_length_onion_optional(uint64_t this_arg) {
37960         LDKInvoiceFeatures this_arg_conv;
37961         this_arg_conv.inner = untag_ptr(this_arg);
37962         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37964         this_arg_conv.is_owned = false;
37965         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
37966 }
37967
37968 void  __attribute__((export_name("TS_InvoiceFeatures_set_variable_length_onion_required"))) TS_InvoiceFeatures_set_variable_length_onion_required(uint64_t this_arg) {
37969         LDKInvoiceFeatures this_arg_conv;
37970         this_arg_conv.inner = untag_ptr(this_arg);
37971         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37973         this_arg_conv.is_owned = false;
37974         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
37975 }
37976
37977 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_variable_length_onion"))) TS_InvoiceFeatures_supports_variable_length_onion(uint64_t this_arg) {
37978         LDKInvoiceFeatures this_arg_conv;
37979         this_arg_conv.inner = untag_ptr(this_arg);
37980         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37982         this_arg_conv.is_owned = false;
37983         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
37984         return ret_conv;
37985 }
37986
37987 jboolean  __attribute__((export_name("TS_InitFeatures_requires_variable_length_onion"))) TS_InitFeatures_requires_variable_length_onion(uint64_t this_arg) {
37988         LDKInitFeatures this_arg_conv;
37989         this_arg_conv.inner = untag_ptr(this_arg);
37990         this_arg_conv.is_owned = ptr_is_owned(this_arg);
37991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37992         this_arg_conv.is_owned = false;
37993         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
37994         return ret_conv;
37995 }
37996
37997 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_variable_length_onion"))) TS_NodeFeatures_requires_variable_length_onion(uint64_t this_arg) {
37998         LDKNodeFeatures this_arg_conv;
37999         this_arg_conv.inner = untag_ptr(this_arg);
38000         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38002         this_arg_conv.is_owned = false;
38003         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
38004         return ret_conv;
38005 }
38006
38007 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_variable_length_onion"))) TS_InvoiceFeatures_requires_variable_length_onion(uint64_t this_arg) {
38008         LDKInvoiceFeatures this_arg_conv;
38009         this_arg_conv.inner = untag_ptr(this_arg);
38010         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38012         this_arg_conv.is_owned = false;
38013         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
38014         return ret_conv;
38015 }
38016
38017 void  __attribute__((export_name("TS_InitFeatures_set_static_remote_key_optional"))) TS_InitFeatures_set_static_remote_key_optional(uint64_t this_arg) {
38018         LDKInitFeatures this_arg_conv;
38019         this_arg_conv.inner = untag_ptr(this_arg);
38020         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38022         this_arg_conv.is_owned = false;
38023         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
38024 }
38025
38026 void  __attribute__((export_name("TS_InitFeatures_set_static_remote_key_required"))) TS_InitFeatures_set_static_remote_key_required(uint64_t this_arg) {
38027         LDKInitFeatures this_arg_conv;
38028         this_arg_conv.inner = untag_ptr(this_arg);
38029         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38031         this_arg_conv.is_owned = false;
38032         InitFeatures_set_static_remote_key_required(&this_arg_conv);
38033 }
38034
38035 jboolean  __attribute__((export_name("TS_InitFeatures_supports_static_remote_key"))) TS_InitFeatures_supports_static_remote_key(uint64_t this_arg) {
38036         LDKInitFeatures this_arg_conv;
38037         this_arg_conv.inner = untag_ptr(this_arg);
38038         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38040         this_arg_conv.is_owned = false;
38041         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
38042         return ret_conv;
38043 }
38044
38045 void  __attribute__((export_name("TS_NodeFeatures_set_static_remote_key_optional"))) TS_NodeFeatures_set_static_remote_key_optional(uint64_t this_arg) {
38046         LDKNodeFeatures this_arg_conv;
38047         this_arg_conv.inner = untag_ptr(this_arg);
38048         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38050         this_arg_conv.is_owned = false;
38051         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
38052 }
38053
38054 void  __attribute__((export_name("TS_NodeFeatures_set_static_remote_key_required"))) TS_NodeFeatures_set_static_remote_key_required(uint64_t this_arg) {
38055         LDKNodeFeatures this_arg_conv;
38056         this_arg_conv.inner = untag_ptr(this_arg);
38057         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38059         this_arg_conv.is_owned = false;
38060         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
38061 }
38062
38063 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_static_remote_key"))) TS_NodeFeatures_supports_static_remote_key(uint64_t this_arg) {
38064         LDKNodeFeatures this_arg_conv;
38065         this_arg_conv.inner = untag_ptr(this_arg);
38066         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38068         this_arg_conv.is_owned = false;
38069         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
38070         return ret_conv;
38071 }
38072
38073 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_static_remote_key_optional"))) TS_ChannelTypeFeatures_set_static_remote_key_optional(uint64_t this_arg) {
38074         LDKChannelTypeFeatures this_arg_conv;
38075         this_arg_conv.inner = untag_ptr(this_arg);
38076         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38078         this_arg_conv.is_owned = false;
38079         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
38080 }
38081
38082 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_static_remote_key_required"))) TS_ChannelTypeFeatures_set_static_remote_key_required(uint64_t this_arg) {
38083         LDKChannelTypeFeatures this_arg_conv;
38084         this_arg_conv.inner = untag_ptr(this_arg);
38085         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38087         this_arg_conv.is_owned = false;
38088         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
38089 }
38090
38091 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_static_remote_key"))) TS_ChannelTypeFeatures_supports_static_remote_key(uint64_t this_arg) {
38092         LDKChannelTypeFeatures this_arg_conv;
38093         this_arg_conv.inner = untag_ptr(this_arg);
38094         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38096         this_arg_conv.is_owned = false;
38097         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
38098         return ret_conv;
38099 }
38100
38101 jboolean  __attribute__((export_name("TS_InitFeatures_requires_static_remote_key"))) TS_InitFeatures_requires_static_remote_key(uint64_t this_arg) {
38102         LDKInitFeatures this_arg_conv;
38103         this_arg_conv.inner = untag_ptr(this_arg);
38104         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38106         this_arg_conv.is_owned = false;
38107         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
38108         return ret_conv;
38109 }
38110
38111 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_static_remote_key"))) TS_NodeFeatures_requires_static_remote_key(uint64_t this_arg) {
38112         LDKNodeFeatures this_arg_conv;
38113         this_arg_conv.inner = untag_ptr(this_arg);
38114         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38116         this_arg_conv.is_owned = false;
38117         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
38118         return ret_conv;
38119 }
38120
38121 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_static_remote_key"))) TS_ChannelTypeFeatures_requires_static_remote_key(uint64_t this_arg) {
38122         LDKChannelTypeFeatures this_arg_conv;
38123         this_arg_conv.inner = untag_ptr(this_arg);
38124         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38126         this_arg_conv.is_owned = false;
38127         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
38128         return ret_conv;
38129 }
38130
38131 void  __attribute__((export_name("TS_InitFeatures_set_payment_secret_optional"))) TS_InitFeatures_set_payment_secret_optional(uint64_t this_arg) {
38132         LDKInitFeatures this_arg_conv;
38133         this_arg_conv.inner = untag_ptr(this_arg);
38134         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38136         this_arg_conv.is_owned = false;
38137         InitFeatures_set_payment_secret_optional(&this_arg_conv);
38138 }
38139
38140 void  __attribute__((export_name("TS_InitFeatures_set_payment_secret_required"))) TS_InitFeatures_set_payment_secret_required(uint64_t this_arg) {
38141         LDKInitFeatures this_arg_conv;
38142         this_arg_conv.inner = untag_ptr(this_arg);
38143         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38145         this_arg_conv.is_owned = false;
38146         InitFeatures_set_payment_secret_required(&this_arg_conv);
38147 }
38148
38149 jboolean  __attribute__((export_name("TS_InitFeatures_supports_payment_secret"))) TS_InitFeatures_supports_payment_secret(uint64_t this_arg) {
38150         LDKInitFeatures this_arg_conv;
38151         this_arg_conv.inner = untag_ptr(this_arg);
38152         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38154         this_arg_conv.is_owned = false;
38155         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
38156         return ret_conv;
38157 }
38158
38159 void  __attribute__((export_name("TS_NodeFeatures_set_payment_secret_optional"))) TS_NodeFeatures_set_payment_secret_optional(uint64_t this_arg) {
38160         LDKNodeFeatures this_arg_conv;
38161         this_arg_conv.inner = untag_ptr(this_arg);
38162         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38164         this_arg_conv.is_owned = false;
38165         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
38166 }
38167
38168 void  __attribute__((export_name("TS_NodeFeatures_set_payment_secret_required"))) TS_NodeFeatures_set_payment_secret_required(uint64_t this_arg) {
38169         LDKNodeFeatures this_arg_conv;
38170         this_arg_conv.inner = untag_ptr(this_arg);
38171         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38173         this_arg_conv.is_owned = false;
38174         NodeFeatures_set_payment_secret_required(&this_arg_conv);
38175 }
38176
38177 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_payment_secret"))) TS_NodeFeatures_supports_payment_secret(uint64_t this_arg) {
38178         LDKNodeFeatures this_arg_conv;
38179         this_arg_conv.inner = untag_ptr(this_arg);
38180         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38182         this_arg_conv.is_owned = false;
38183         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
38184         return ret_conv;
38185 }
38186
38187 void  __attribute__((export_name("TS_InvoiceFeatures_set_payment_secret_optional"))) TS_InvoiceFeatures_set_payment_secret_optional(uint64_t this_arg) {
38188         LDKInvoiceFeatures this_arg_conv;
38189         this_arg_conv.inner = untag_ptr(this_arg);
38190         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38192         this_arg_conv.is_owned = false;
38193         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
38194 }
38195
38196 void  __attribute__((export_name("TS_InvoiceFeatures_set_payment_secret_required"))) TS_InvoiceFeatures_set_payment_secret_required(uint64_t this_arg) {
38197         LDKInvoiceFeatures this_arg_conv;
38198         this_arg_conv.inner = untag_ptr(this_arg);
38199         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38201         this_arg_conv.is_owned = false;
38202         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
38203 }
38204
38205 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_payment_secret"))) TS_InvoiceFeatures_supports_payment_secret(uint64_t this_arg) {
38206         LDKInvoiceFeatures this_arg_conv;
38207         this_arg_conv.inner = untag_ptr(this_arg);
38208         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38210         this_arg_conv.is_owned = false;
38211         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
38212         return ret_conv;
38213 }
38214
38215 jboolean  __attribute__((export_name("TS_InitFeatures_requires_payment_secret"))) TS_InitFeatures_requires_payment_secret(uint64_t this_arg) {
38216         LDKInitFeatures this_arg_conv;
38217         this_arg_conv.inner = untag_ptr(this_arg);
38218         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38220         this_arg_conv.is_owned = false;
38221         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
38222         return ret_conv;
38223 }
38224
38225 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_payment_secret"))) TS_NodeFeatures_requires_payment_secret(uint64_t this_arg) {
38226         LDKNodeFeatures this_arg_conv;
38227         this_arg_conv.inner = untag_ptr(this_arg);
38228         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38230         this_arg_conv.is_owned = false;
38231         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
38232         return ret_conv;
38233 }
38234
38235 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_payment_secret"))) TS_InvoiceFeatures_requires_payment_secret(uint64_t this_arg) {
38236         LDKInvoiceFeatures this_arg_conv;
38237         this_arg_conv.inner = untag_ptr(this_arg);
38238         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38240         this_arg_conv.is_owned = false;
38241         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
38242         return ret_conv;
38243 }
38244
38245 void  __attribute__((export_name("TS_InitFeatures_set_basic_mpp_optional"))) TS_InitFeatures_set_basic_mpp_optional(uint64_t this_arg) {
38246         LDKInitFeatures this_arg_conv;
38247         this_arg_conv.inner = untag_ptr(this_arg);
38248         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38250         this_arg_conv.is_owned = false;
38251         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
38252 }
38253
38254 void  __attribute__((export_name("TS_InitFeatures_set_basic_mpp_required"))) TS_InitFeatures_set_basic_mpp_required(uint64_t this_arg) {
38255         LDKInitFeatures this_arg_conv;
38256         this_arg_conv.inner = untag_ptr(this_arg);
38257         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38259         this_arg_conv.is_owned = false;
38260         InitFeatures_set_basic_mpp_required(&this_arg_conv);
38261 }
38262
38263 jboolean  __attribute__((export_name("TS_InitFeatures_supports_basic_mpp"))) TS_InitFeatures_supports_basic_mpp(uint64_t this_arg) {
38264         LDKInitFeatures this_arg_conv;
38265         this_arg_conv.inner = untag_ptr(this_arg);
38266         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38268         this_arg_conv.is_owned = false;
38269         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
38270         return ret_conv;
38271 }
38272
38273 void  __attribute__((export_name("TS_NodeFeatures_set_basic_mpp_optional"))) TS_NodeFeatures_set_basic_mpp_optional(uint64_t this_arg) {
38274         LDKNodeFeatures this_arg_conv;
38275         this_arg_conv.inner = untag_ptr(this_arg);
38276         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38278         this_arg_conv.is_owned = false;
38279         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
38280 }
38281
38282 void  __attribute__((export_name("TS_NodeFeatures_set_basic_mpp_required"))) TS_NodeFeatures_set_basic_mpp_required(uint64_t this_arg) {
38283         LDKNodeFeatures this_arg_conv;
38284         this_arg_conv.inner = untag_ptr(this_arg);
38285         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38287         this_arg_conv.is_owned = false;
38288         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
38289 }
38290
38291 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_basic_mpp"))) TS_NodeFeatures_supports_basic_mpp(uint64_t this_arg) {
38292         LDKNodeFeatures this_arg_conv;
38293         this_arg_conv.inner = untag_ptr(this_arg);
38294         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38296         this_arg_conv.is_owned = false;
38297         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
38298         return ret_conv;
38299 }
38300
38301 void  __attribute__((export_name("TS_InvoiceFeatures_set_basic_mpp_optional"))) TS_InvoiceFeatures_set_basic_mpp_optional(uint64_t this_arg) {
38302         LDKInvoiceFeatures this_arg_conv;
38303         this_arg_conv.inner = untag_ptr(this_arg);
38304         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38306         this_arg_conv.is_owned = false;
38307         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
38308 }
38309
38310 void  __attribute__((export_name("TS_InvoiceFeatures_set_basic_mpp_required"))) TS_InvoiceFeatures_set_basic_mpp_required(uint64_t this_arg) {
38311         LDKInvoiceFeatures this_arg_conv;
38312         this_arg_conv.inner = untag_ptr(this_arg);
38313         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38315         this_arg_conv.is_owned = false;
38316         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
38317 }
38318
38319 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_basic_mpp"))) TS_InvoiceFeatures_supports_basic_mpp(uint64_t this_arg) {
38320         LDKInvoiceFeatures this_arg_conv;
38321         this_arg_conv.inner = untag_ptr(this_arg);
38322         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38324         this_arg_conv.is_owned = false;
38325         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
38326         return ret_conv;
38327 }
38328
38329 jboolean  __attribute__((export_name("TS_InitFeatures_requires_basic_mpp"))) TS_InitFeatures_requires_basic_mpp(uint64_t this_arg) {
38330         LDKInitFeatures this_arg_conv;
38331         this_arg_conv.inner = untag_ptr(this_arg);
38332         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38334         this_arg_conv.is_owned = false;
38335         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
38336         return ret_conv;
38337 }
38338
38339 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_basic_mpp"))) TS_NodeFeatures_requires_basic_mpp(uint64_t this_arg) {
38340         LDKNodeFeatures this_arg_conv;
38341         this_arg_conv.inner = untag_ptr(this_arg);
38342         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38344         this_arg_conv.is_owned = false;
38345         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
38346         return ret_conv;
38347 }
38348
38349 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_basic_mpp"))) TS_InvoiceFeatures_requires_basic_mpp(uint64_t this_arg) {
38350         LDKInvoiceFeatures this_arg_conv;
38351         this_arg_conv.inner = untag_ptr(this_arg);
38352         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38354         this_arg_conv.is_owned = false;
38355         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
38356         return ret_conv;
38357 }
38358
38359 void  __attribute__((export_name("TS_InitFeatures_set_wumbo_optional"))) TS_InitFeatures_set_wumbo_optional(uint64_t this_arg) {
38360         LDKInitFeatures this_arg_conv;
38361         this_arg_conv.inner = untag_ptr(this_arg);
38362         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38364         this_arg_conv.is_owned = false;
38365         InitFeatures_set_wumbo_optional(&this_arg_conv);
38366 }
38367
38368 void  __attribute__((export_name("TS_InitFeatures_set_wumbo_required"))) TS_InitFeatures_set_wumbo_required(uint64_t this_arg) {
38369         LDKInitFeatures this_arg_conv;
38370         this_arg_conv.inner = untag_ptr(this_arg);
38371         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38373         this_arg_conv.is_owned = false;
38374         InitFeatures_set_wumbo_required(&this_arg_conv);
38375 }
38376
38377 jboolean  __attribute__((export_name("TS_InitFeatures_supports_wumbo"))) TS_InitFeatures_supports_wumbo(uint64_t this_arg) {
38378         LDKInitFeatures this_arg_conv;
38379         this_arg_conv.inner = untag_ptr(this_arg);
38380         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38382         this_arg_conv.is_owned = false;
38383         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
38384         return ret_conv;
38385 }
38386
38387 void  __attribute__((export_name("TS_NodeFeatures_set_wumbo_optional"))) TS_NodeFeatures_set_wumbo_optional(uint64_t this_arg) {
38388         LDKNodeFeatures this_arg_conv;
38389         this_arg_conv.inner = untag_ptr(this_arg);
38390         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38392         this_arg_conv.is_owned = false;
38393         NodeFeatures_set_wumbo_optional(&this_arg_conv);
38394 }
38395
38396 void  __attribute__((export_name("TS_NodeFeatures_set_wumbo_required"))) TS_NodeFeatures_set_wumbo_required(uint64_t this_arg) {
38397         LDKNodeFeatures this_arg_conv;
38398         this_arg_conv.inner = untag_ptr(this_arg);
38399         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38401         this_arg_conv.is_owned = false;
38402         NodeFeatures_set_wumbo_required(&this_arg_conv);
38403 }
38404
38405 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_wumbo"))) TS_NodeFeatures_supports_wumbo(uint64_t this_arg) {
38406         LDKNodeFeatures this_arg_conv;
38407         this_arg_conv.inner = untag_ptr(this_arg);
38408         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38410         this_arg_conv.is_owned = false;
38411         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
38412         return ret_conv;
38413 }
38414
38415 jboolean  __attribute__((export_name("TS_InitFeatures_requires_wumbo"))) TS_InitFeatures_requires_wumbo(uint64_t this_arg) {
38416         LDKInitFeatures this_arg_conv;
38417         this_arg_conv.inner = untag_ptr(this_arg);
38418         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38420         this_arg_conv.is_owned = false;
38421         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
38422         return ret_conv;
38423 }
38424
38425 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_wumbo"))) TS_NodeFeatures_requires_wumbo(uint64_t this_arg) {
38426         LDKNodeFeatures this_arg_conv;
38427         this_arg_conv.inner = untag_ptr(this_arg);
38428         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38430         this_arg_conv.is_owned = false;
38431         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
38432         return ret_conv;
38433 }
38434
38435 void  __attribute__((export_name("TS_InitFeatures_set_shutdown_any_segwit_optional"))) TS_InitFeatures_set_shutdown_any_segwit_optional(uint64_t this_arg) {
38436         LDKInitFeatures this_arg_conv;
38437         this_arg_conv.inner = untag_ptr(this_arg);
38438         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38440         this_arg_conv.is_owned = false;
38441         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
38442 }
38443
38444 void  __attribute__((export_name("TS_InitFeatures_set_shutdown_any_segwit_required"))) TS_InitFeatures_set_shutdown_any_segwit_required(uint64_t this_arg) {
38445         LDKInitFeatures this_arg_conv;
38446         this_arg_conv.inner = untag_ptr(this_arg);
38447         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38449         this_arg_conv.is_owned = false;
38450         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
38451 }
38452
38453 jboolean  __attribute__((export_name("TS_InitFeatures_supports_shutdown_anysegwit"))) TS_InitFeatures_supports_shutdown_anysegwit(uint64_t this_arg) {
38454         LDKInitFeatures this_arg_conv;
38455         this_arg_conv.inner = untag_ptr(this_arg);
38456         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38458         this_arg_conv.is_owned = false;
38459         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
38460         return ret_conv;
38461 }
38462
38463 void  __attribute__((export_name("TS_NodeFeatures_set_shutdown_any_segwit_optional"))) TS_NodeFeatures_set_shutdown_any_segwit_optional(uint64_t this_arg) {
38464         LDKNodeFeatures this_arg_conv;
38465         this_arg_conv.inner = untag_ptr(this_arg);
38466         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38468         this_arg_conv.is_owned = false;
38469         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
38470 }
38471
38472 void  __attribute__((export_name("TS_NodeFeatures_set_shutdown_any_segwit_required"))) TS_NodeFeatures_set_shutdown_any_segwit_required(uint64_t this_arg) {
38473         LDKNodeFeatures this_arg_conv;
38474         this_arg_conv.inner = untag_ptr(this_arg);
38475         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38477         this_arg_conv.is_owned = false;
38478         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
38479 }
38480
38481 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_shutdown_anysegwit"))) TS_NodeFeatures_supports_shutdown_anysegwit(uint64_t this_arg) {
38482         LDKNodeFeatures this_arg_conv;
38483         this_arg_conv.inner = untag_ptr(this_arg);
38484         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38486         this_arg_conv.is_owned = false;
38487         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
38488         return ret_conv;
38489 }
38490
38491 jboolean  __attribute__((export_name("TS_InitFeatures_requires_shutdown_anysegwit"))) TS_InitFeatures_requires_shutdown_anysegwit(uint64_t this_arg) {
38492         LDKInitFeatures this_arg_conv;
38493         this_arg_conv.inner = untag_ptr(this_arg);
38494         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38496         this_arg_conv.is_owned = false;
38497         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
38498         return ret_conv;
38499 }
38500
38501 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_shutdown_anysegwit"))) TS_NodeFeatures_requires_shutdown_anysegwit(uint64_t this_arg) {
38502         LDKNodeFeatures this_arg_conv;
38503         this_arg_conv.inner = untag_ptr(this_arg);
38504         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38506         this_arg_conv.is_owned = false;
38507         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
38508         return ret_conv;
38509 }
38510
38511 void  __attribute__((export_name("TS_InitFeatures_set_onion_messages_optional"))) TS_InitFeatures_set_onion_messages_optional(uint64_t this_arg) {
38512         LDKInitFeatures this_arg_conv;
38513         this_arg_conv.inner = untag_ptr(this_arg);
38514         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38516         this_arg_conv.is_owned = false;
38517         InitFeatures_set_onion_messages_optional(&this_arg_conv);
38518 }
38519
38520 void  __attribute__((export_name("TS_InitFeatures_set_onion_messages_required"))) TS_InitFeatures_set_onion_messages_required(uint64_t this_arg) {
38521         LDKInitFeatures this_arg_conv;
38522         this_arg_conv.inner = untag_ptr(this_arg);
38523         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38525         this_arg_conv.is_owned = false;
38526         InitFeatures_set_onion_messages_required(&this_arg_conv);
38527 }
38528
38529 jboolean  __attribute__((export_name("TS_InitFeatures_supports_onion_messages"))) TS_InitFeatures_supports_onion_messages(uint64_t this_arg) {
38530         LDKInitFeatures this_arg_conv;
38531         this_arg_conv.inner = untag_ptr(this_arg);
38532         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38534         this_arg_conv.is_owned = false;
38535         jboolean ret_conv = InitFeatures_supports_onion_messages(&this_arg_conv);
38536         return ret_conv;
38537 }
38538
38539 void  __attribute__((export_name("TS_NodeFeatures_set_onion_messages_optional"))) TS_NodeFeatures_set_onion_messages_optional(uint64_t this_arg) {
38540         LDKNodeFeatures this_arg_conv;
38541         this_arg_conv.inner = untag_ptr(this_arg);
38542         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38544         this_arg_conv.is_owned = false;
38545         NodeFeatures_set_onion_messages_optional(&this_arg_conv);
38546 }
38547
38548 void  __attribute__((export_name("TS_NodeFeatures_set_onion_messages_required"))) TS_NodeFeatures_set_onion_messages_required(uint64_t this_arg) {
38549         LDKNodeFeatures this_arg_conv;
38550         this_arg_conv.inner = untag_ptr(this_arg);
38551         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38553         this_arg_conv.is_owned = false;
38554         NodeFeatures_set_onion_messages_required(&this_arg_conv);
38555 }
38556
38557 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_onion_messages"))) TS_NodeFeatures_supports_onion_messages(uint64_t this_arg) {
38558         LDKNodeFeatures this_arg_conv;
38559         this_arg_conv.inner = untag_ptr(this_arg);
38560         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38562         this_arg_conv.is_owned = false;
38563         jboolean ret_conv = NodeFeatures_supports_onion_messages(&this_arg_conv);
38564         return ret_conv;
38565 }
38566
38567 jboolean  __attribute__((export_name("TS_InitFeatures_requires_onion_messages"))) TS_InitFeatures_requires_onion_messages(uint64_t this_arg) {
38568         LDKInitFeatures this_arg_conv;
38569         this_arg_conv.inner = untag_ptr(this_arg);
38570         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38572         this_arg_conv.is_owned = false;
38573         jboolean ret_conv = InitFeatures_requires_onion_messages(&this_arg_conv);
38574         return ret_conv;
38575 }
38576
38577 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_onion_messages"))) TS_NodeFeatures_requires_onion_messages(uint64_t this_arg) {
38578         LDKNodeFeatures this_arg_conv;
38579         this_arg_conv.inner = untag_ptr(this_arg);
38580         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38582         this_arg_conv.is_owned = false;
38583         jboolean ret_conv = NodeFeatures_requires_onion_messages(&this_arg_conv);
38584         return ret_conv;
38585 }
38586
38587 void  __attribute__((export_name("TS_InitFeatures_set_channel_type_optional"))) TS_InitFeatures_set_channel_type_optional(uint64_t this_arg) {
38588         LDKInitFeatures this_arg_conv;
38589         this_arg_conv.inner = untag_ptr(this_arg);
38590         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38592         this_arg_conv.is_owned = false;
38593         InitFeatures_set_channel_type_optional(&this_arg_conv);
38594 }
38595
38596 void  __attribute__((export_name("TS_InitFeatures_set_channel_type_required"))) TS_InitFeatures_set_channel_type_required(uint64_t this_arg) {
38597         LDKInitFeatures this_arg_conv;
38598         this_arg_conv.inner = untag_ptr(this_arg);
38599         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38601         this_arg_conv.is_owned = false;
38602         InitFeatures_set_channel_type_required(&this_arg_conv);
38603 }
38604
38605 jboolean  __attribute__((export_name("TS_InitFeatures_supports_channel_type"))) TS_InitFeatures_supports_channel_type(uint64_t this_arg) {
38606         LDKInitFeatures this_arg_conv;
38607         this_arg_conv.inner = untag_ptr(this_arg);
38608         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38610         this_arg_conv.is_owned = false;
38611         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
38612         return ret_conv;
38613 }
38614
38615 void  __attribute__((export_name("TS_NodeFeatures_set_channel_type_optional"))) TS_NodeFeatures_set_channel_type_optional(uint64_t this_arg) {
38616         LDKNodeFeatures this_arg_conv;
38617         this_arg_conv.inner = untag_ptr(this_arg);
38618         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38620         this_arg_conv.is_owned = false;
38621         NodeFeatures_set_channel_type_optional(&this_arg_conv);
38622 }
38623
38624 void  __attribute__((export_name("TS_NodeFeatures_set_channel_type_required"))) TS_NodeFeatures_set_channel_type_required(uint64_t this_arg) {
38625         LDKNodeFeatures this_arg_conv;
38626         this_arg_conv.inner = untag_ptr(this_arg);
38627         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38629         this_arg_conv.is_owned = false;
38630         NodeFeatures_set_channel_type_required(&this_arg_conv);
38631 }
38632
38633 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_channel_type"))) TS_NodeFeatures_supports_channel_type(uint64_t this_arg) {
38634         LDKNodeFeatures this_arg_conv;
38635         this_arg_conv.inner = untag_ptr(this_arg);
38636         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38638         this_arg_conv.is_owned = false;
38639         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
38640         return ret_conv;
38641 }
38642
38643 jboolean  __attribute__((export_name("TS_InitFeatures_requires_channel_type"))) TS_InitFeatures_requires_channel_type(uint64_t this_arg) {
38644         LDKInitFeatures this_arg_conv;
38645         this_arg_conv.inner = untag_ptr(this_arg);
38646         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38648         this_arg_conv.is_owned = false;
38649         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
38650         return ret_conv;
38651 }
38652
38653 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_channel_type"))) TS_NodeFeatures_requires_channel_type(uint64_t this_arg) {
38654         LDKNodeFeatures this_arg_conv;
38655         this_arg_conv.inner = untag_ptr(this_arg);
38656         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38658         this_arg_conv.is_owned = false;
38659         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
38660         return ret_conv;
38661 }
38662
38663 void  __attribute__((export_name("TS_InitFeatures_set_scid_privacy_optional"))) TS_InitFeatures_set_scid_privacy_optional(uint64_t this_arg) {
38664         LDKInitFeatures this_arg_conv;
38665         this_arg_conv.inner = untag_ptr(this_arg);
38666         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38668         this_arg_conv.is_owned = false;
38669         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
38670 }
38671
38672 void  __attribute__((export_name("TS_InitFeatures_set_scid_privacy_required"))) TS_InitFeatures_set_scid_privacy_required(uint64_t this_arg) {
38673         LDKInitFeatures this_arg_conv;
38674         this_arg_conv.inner = untag_ptr(this_arg);
38675         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38677         this_arg_conv.is_owned = false;
38678         InitFeatures_set_scid_privacy_required(&this_arg_conv);
38679 }
38680
38681 jboolean  __attribute__((export_name("TS_InitFeatures_supports_scid_privacy"))) TS_InitFeatures_supports_scid_privacy(uint64_t this_arg) {
38682         LDKInitFeatures this_arg_conv;
38683         this_arg_conv.inner = untag_ptr(this_arg);
38684         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38686         this_arg_conv.is_owned = false;
38687         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
38688         return ret_conv;
38689 }
38690
38691 void  __attribute__((export_name("TS_NodeFeatures_set_scid_privacy_optional"))) TS_NodeFeatures_set_scid_privacy_optional(uint64_t this_arg) {
38692         LDKNodeFeatures this_arg_conv;
38693         this_arg_conv.inner = untag_ptr(this_arg);
38694         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38696         this_arg_conv.is_owned = false;
38697         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
38698 }
38699
38700 void  __attribute__((export_name("TS_NodeFeatures_set_scid_privacy_required"))) TS_NodeFeatures_set_scid_privacy_required(uint64_t this_arg) {
38701         LDKNodeFeatures this_arg_conv;
38702         this_arg_conv.inner = untag_ptr(this_arg);
38703         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38705         this_arg_conv.is_owned = false;
38706         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
38707 }
38708
38709 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_scid_privacy"))) TS_NodeFeatures_supports_scid_privacy(uint64_t this_arg) {
38710         LDKNodeFeatures this_arg_conv;
38711         this_arg_conv.inner = untag_ptr(this_arg);
38712         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38714         this_arg_conv.is_owned = false;
38715         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
38716         return ret_conv;
38717 }
38718
38719 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_scid_privacy_optional"))) TS_ChannelTypeFeatures_set_scid_privacy_optional(uint64_t this_arg) {
38720         LDKChannelTypeFeatures this_arg_conv;
38721         this_arg_conv.inner = untag_ptr(this_arg);
38722         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38724         this_arg_conv.is_owned = false;
38725         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
38726 }
38727
38728 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_scid_privacy_required"))) TS_ChannelTypeFeatures_set_scid_privacy_required(uint64_t this_arg) {
38729         LDKChannelTypeFeatures this_arg_conv;
38730         this_arg_conv.inner = untag_ptr(this_arg);
38731         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38733         this_arg_conv.is_owned = false;
38734         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
38735 }
38736
38737 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_scid_privacy"))) TS_ChannelTypeFeatures_supports_scid_privacy(uint64_t this_arg) {
38738         LDKChannelTypeFeatures this_arg_conv;
38739         this_arg_conv.inner = untag_ptr(this_arg);
38740         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38742         this_arg_conv.is_owned = false;
38743         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
38744         return ret_conv;
38745 }
38746
38747 jboolean  __attribute__((export_name("TS_InitFeatures_requires_scid_privacy"))) TS_InitFeatures_requires_scid_privacy(uint64_t this_arg) {
38748         LDKInitFeatures this_arg_conv;
38749         this_arg_conv.inner = untag_ptr(this_arg);
38750         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38752         this_arg_conv.is_owned = false;
38753         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
38754         return ret_conv;
38755 }
38756
38757 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_scid_privacy"))) TS_NodeFeatures_requires_scid_privacy(uint64_t this_arg) {
38758         LDKNodeFeatures this_arg_conv;
38759         this_arg_conv.inner = untag_ptr(this_arg);
38760         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38762         this_arg_conv.is_owned = false;
38763         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
38764         return ret_conv;
38765 }
38766
38767 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_scid_privacy"))) TS_ChannelTypeFeatures_requires_scid_privacy(uint64_t this_arg) {
38768         LDKChannelTypeFeatures this_arg_conv;
38769         this_arg_conv.inner = untag_ptr(this_arg);
38770         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38772         this_arg_conv.is_owned = false;
38773         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
38774         return ret_conv;
38775 }
38776
38777 void  __attribute__((export_name("TS_InitFeatures_set_zero_conf_optional"))) TS_InitFeatures_set_zero_conf_optional(uint64_t this_arg) {
38778         LDKInitFeatures this_arg_conv;
38779         this_arg_conv.inner = untag_ptr(this_arg);
38780         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38782         this_arg_conv.is_owned = false;
38783         InitFeatures_set_zero_conf_optional(&this_arg_conv);
38784 }
38785
38786 void  __attribute__((export_name("TS_InitFeatures_set_zero_conf_required"))) TS_InitFeatures_set_zero_conf_required(uint64_t this_arg) {
38787         LDKInitFeatures this_arg_conv;
38788         this_arg_conv.inner = untag_ptr(this_arg);
38789         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38791         this_arg_conv.is_owned = false;
38792         InitFeatures_set_zero_conf_required(&this_arg_conv);
38793 }
38794
38795 jboolean  __attribute__((export_name("TS_InitFeatures_supports_zero_conf"))) TS_InitFeatures_supports_zero_conf(uint64_t this_arg) {
38796         LDKInitFeatures this_arg_conv;
38797         this_arg_conv.inner = untag_ptr(this_arg);
38798         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38800         this_arg_conv.is_owned = false;
38801         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
38802         return ret_conv;
38803 }
38804
38805 void  __attribute__((export_name("TS_NodeFeatures_set_zero_conf_optional"))) TS_NodeFeatures_set_zero_conf_optional(uint64_t this_arg) {
38806         LDKNodeFeatures this_arg_conv;
38807         this_arg_conv.inner = untag_ptr(this_arg);
38808         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38810         this_arg_conv.is_owned = false;
38811         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
38812 }
38813
38814 void  __attribute__((export_name("TS_NodeFeatures_set_zero_conf_required"))) TS_NodeFeatures_set_zero_conf_required(uint64_t this_arg) {
38815         LDKNodeFeatures this_arg_conv;
38816         this_arg_conv.inner = untag_ptr(this_arg);
38817         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38819         this_arg_conv.is_owned = false;
38820         NodeFeatures_set_zero_conf_required(&this_arg_conv);
38821 }
38822
38823 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_zero_conf"))) TS_NodeFeatures_supports_zero_conf(uint64_t this_arg) {
38824         LDKNodeFeatures this_arg_conv;
38825         this_arg_conv.inner = untag_ptr(this_arg);
38826         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38828         this_arg_conv.is_owned = false;
38829         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
38830         return ret_conv;
38831 }
38832
38833 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_zero_conf_optional"))) TS_ChannelTypeFeatures_set_zero_conf_optional(uint64_t this_arg) {
38834         LDKChannelTypeFeatures this_arg_conv;
38835         this_arg_conv.inner = untag_ptr(this_arg);
38836         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38838         this_arg_conv.is_owned = false;
38839         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
38840 }
38841
38842 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_zero_conf_required"))) TS_ChannelTypeFeatures_set_zero_conf_required(uint64_t this_arg) {
38843         LDKChannelTypeFeatures this_arg_conv;
38844         this_arg_conv.inner = untag_ptr(this_arg);
38845         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38847         this_arg_conv.is_owned = false;
38848         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
38849 }
38850
38851 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_zero_conf"))) TS_ChannelTypeFeatures_supports_zero_conf(uint64_t this_arg) {
38852         LDKChannelTypeFeatures this_arg_conv;
38853         this_arg_conv.inner = untag_ptr(this_arg);
38854         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38856         this_arg_conv.is_owned = false;
38857         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
38858         return ret_conv;
38859 }
38860
38861 jboolean  __attribute__((export_name("TS_InitFeatures_requires_zero_conf"))) TS_InitFeatures_requires_zero_conf(uint64_t this_arg) {
38862         LDKInitFeatures this_arg_conv;
38863         this_arg_conv.inner = untag_ptr(this_arg);
38864         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38866         this_arg_conv.is_owned = false;
38867         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
38868         return ret_conv;
38869 }
38870
38871 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_zero_conf"))) TS_NodeFeatures_requires_zero_conf(uint64_t this_arg) {
38872         LDKNodeFeatures this_arg_conv;
38873         this_arg_conv.inner = untag_ptr(this_arg);
38874         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38876         this_arg_conv.is_owned = false;
38877         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
38878         return ret_conv;
38879 }
38880
38881 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_zero_conf"))) TS_ChannelTypeFeatures_requires_zero_conf(uint64_t this_arg) {
38882         LDKChannelTypeFeatures this_arg_conv;
38883         this_arg_conv.inner = untag_ptr(this_arg);
38884         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38886         this_arg_conv.is_owned = false;
38887         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
38888         return ret_conv;
38889 }
38890
38891 void  __attribute__((export_name("TS_NodeFeatures_set_keysend_optional"))) TS_NodeFeatures_set_keysend_optional(uint64_t this_arg) {
38892         LDKNodeFeatures this_arg_conv;
38893         this_arg_conv.inner = untag_ptr(this_arg);
38894         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38896         this_arg_conv.is_owned = false;
38897         NodeFeatures_set_keysend_optional(&this_arg_conv);
38898 }
38899
38900 void  __attribute__((export_name("TS_NodeFeatures_set_keysend_required"))) TS_NodeFeatures_set_keysend_required(uint64_t this_arg) {
38901         LDKNodeFeatures this_arg_conv;
38902         this_arg_conv.inner = untag_ptr(this_arg);
38903         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38905         this_arg_conv.is_owned = false;
38906         NodeFeatures_set_keysend_required(&this_arg_conv);
38907 }
38908
38909 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_keysend"))) TS_NodeFeatures_supports_keysend(uint64_t this_arg) {
38910         LDKNodeFeatures this_arg_conv;
38911         this_arg_conv.inner = untag_ptr(this_arg);
38912         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38914         this_arg_conv.is_owned = false;
38915         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
38916         return ret_conv;
38917 }
38918
38919 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_keysend"))) TS_NodeFeatures_requires_keysend(uint64_t this_arg) {
38920         LDKNodeFeatures this_arg_conv;
38921         this_arg_conv.inner = untag_ptr(this_arg);
38922         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38924         this_arg_conv.is_owned = false;
38925         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
38926         return ret_conv;
38927 }
38928
38929 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint64_t this_obj) {
38930         LDKShutdownScript this_obj_conv;
38931         this_obj_conv.inner = untag_ptr(this_obj);
38932         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38934         ShutdownScript_free(this_obj_conv);
38935 }
38936
38937 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
38938         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
38939         uint64_t ret_ref = 0;
38940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38941         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38942         return ret_ref;
38943 }
38944 int64_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint64_t arg) {
38945         LDKShutdownScript arg_conv;
38946         arg_conv.inner = untag_ptr(arg);
38947         arg_conv.is_owned = ptr_is_owned(arg);
38948         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38949         arg_conv.is_owned = false;
38950         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
38951         return ret_conv;
38952 }
38953
38954 uint64_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint64_t orig) {
38955         LDKShutdownScript orig_conv;
38956         orig_conv.inner = untag_ptr(orig);
38957         orig_conv.is_owned = ptr_is_owned(orig);
38958         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38959         orig_conv.is_owned = false;
38960         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
38961         uint64_t ret_ref = 0;
38962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38963         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38964         return ret_ref;
38965 }
38966
38967 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint64_t this_obj) {
38968         LDKInvalidShutdownScript this_obj_conv;
38969         this_obj_conv.inner = untag_ptr(this_obj);
38970         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38972         InvalidShutdownScript_free(this_obj_conv);
38973 }
38974
38975 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint64_t this_ptr) {
38976         LDKInvalidShutdownScript this_ptr_conv;
38977         this_ptr_conv.inner = untag_ptr(this_ptr);
38978         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38980         this_ptr_conv.is_owned = false;
38981         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
38982         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38983         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38984         return ret_arr;
38985 }
38986
38987 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint64_t this_ptr, int8_tArray val) {
38988         LDKInvalidShutdownScript this_ptr_conv;
38989         this_ptr_conv.inner = untag_ptr(this_ptr);
38990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38992         this_ptr_conv.is_owned = false;
38993         LDKCVec_u8Z val_ref;
38994         val_ref.datalen = val->arr_len;
38995         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
38996         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
38997         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
38998 }
38999
39000 uint64_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
39001         LDKCVec_u8Z script_arg_ref;
39002         script_arg_ref.datalen = script_arg->arr_len;
39003         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
39004         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
39005         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
39006         uint64_t ret_ref = 0;
39007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39008         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39009         return ret_ref;
39010 }
39011
39012 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
39013         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
39014         uint64_t ret_ref = 0;
39015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39016         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39017         return ret_ref;
39018 }
39019 int64_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint64_t arg) {
39020         LDKInvalidShutdownScript arg_conv;
39021         arg_conv.inner = untag_ptr(arg);
39022         arg_conv.is_owned = ptr_is_owned(arg);
39023         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39024         arg_conv.is_owned = false;
39025         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
39026         return ret_conv;
39027 }
39028
39029 uint64_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint64_t orig) {
39030         LDKInvalidShutdownScript orig_conv;
39031         orig_conv.inner = untag_ptr(orig);
39032         orig_conv.is_owned = ptr_is_owned(orig);
39033         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39034         orig_conv.is_owned = false;
39035         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
39036         uint64_t ret_ref = 0;
39037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39038         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39039         return ret_ref;
39040 }
39041
39042 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint64_t obj) {
39043         LDKShutdownScript obj_conv;
39044         obj_conv.inner = untag_ptr(obj);
39045         obj_conv.is_owned = ptr_is_owned(obj);
39046         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39047         obj_conv.is_owned = false;
39048         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
39049         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39050         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39051         CVec_u8Z_free(ret_var);
39052         return ret_arr;
39053 }
39054
39055 uint64_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
39056         LDKu8slice ser_ref;
39057         ser_ref.datalen = ser->arr_len;
39058         ser_ref.data = ser->elems;
39059         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
39060         *ret_conv = ShutdownScript_read(ser_ref);
39061         FREE(ser);
39062         return tag_ptr(ret_conv, true);
39063 }
39064
39065 uint64_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
39066         unsigned char pubkey_hash_arr[20];
39067         CHECK(pubkey_hash->arr_len == 20);
39068         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
39069         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
39070         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
39071         uint64_t ret_ref = 0;
39072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39073         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39074         return ret_ref;
39075 }
39076
39077 uint64_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
39078         unsigned char script_hash_arr[32];
39079         CHECK(script_hash->arr_len == 32);
39080         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
39081         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
39082         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
39083         uint64_t ret_ref = 0;
39084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39085         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39086         return ret_ref;
39087 }
39088
39089 uint64_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
39090         
39091         LDKu8slice program_ref;
39092         program_ref.datalen = program->arr_len;
39093         program_ref.data = program->elems;
39094         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
39095         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
39096         FREE(program);
39097         return tag_ptr(ret_conv, true);
39098 }
39099
39100 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint64_t this_arg) {
39101         LDKShutdownScript this_arg_conv;
39102         this_arg_conv.inner = untag_ptr(this_arg);
39103         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39105         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
39106         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
39107         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39108         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39109         CVec_u8Z_free(ret_var);
39110         return ret_arr;
39111 }
39112
39113 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint64_t this_arg) {
39114         LDKShutdownScript this_arg_conv;
39115         this_arg_conv.inner = untag_ptr(this_arg);
39116         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39118         this_arg_conv.is_owned = false;
39119         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39120         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
39121         return ret_arr;
39122 }
39123
39124 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint64_t this_arg, uint64_t features) {
39125         LDKShutdownScript this_arg_conv;
39126         this_arg_conv.inner = untag_ptr(this_arg);
39127         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39129         this_arg_conv.is_owned = false;
39130         LDKInitFeatures features_conv;
39131         features_conv.inner = untag_ptr(features);
39132         features_conv.is_owned = ptr_is_owned(features);
39133         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
39134         features_conv.is_owned = false;
39135         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
39136         return ret_conv;
39137 }
39138
39139 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint64_t this_ptr) {
39140         if (!ptr_is_owned(this_ptr)) return;
39141         void* this_ptr_ptr = untag_ptr(this_ptr);
39142         CHECK_ACCESS(this_ptr_ptr);
39143         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
39144         FREE(untag_ptr(this_ptr));
39145         CustomMessageReader_free(this_ptr_conv);
39146 }
39147
39148 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
39149         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39150         *ret_ret = Type_clone(arg);
39151         return tag_ptr(ret_ret, true);
39152 }
39153 int64_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint64_t arg) {
39154         void* arg_ptr = untag_ptr(arg);
39155         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
39156         LDKType* arg_conv = (LDKType*)arg_ptr;
39157         int64_t ret_conv = Type_clone_ptr(arg_conv);
39158         return ret_conv;
39159 }
39160
39161 uint64_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint64_t orig) {
39162         void* orig_ptr = untag_ptr(orig);
39163         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
39164         LDKType* orig_conv = (LDKType*)orig_ptr;
39165         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39166         *ret_ret = Type_clone(orig_conv);
39167         return tag_ptr(ret_ret, true);
39168 }
39169
39170 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint64_t this_ptr) {
39171         if (!ptr_is_owned(this_ptr)) return;
39172         void* this_ptr_ptr = untag_ptr(this_ptr);
39173         CHECK_ACCESS(this_ptr_ptr);
39174         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
39175         FREE(untag_ptr(this_ptr));
39176         Type_free(this_ptr_conv);
39177 }
39178
39179 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint64_t this_obj) {
39180         LDKNodeId this_obj_conv;
39181         this_obj_conv.inner = untag_ptr(this_obj);
39182         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39184         NodeId_free(this_obj_conv);
39185 }
39186
39187 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
39188         LDKNodeId ret_var = NodeId_clone(arg);
39189         uint64_t ret_ref = 0;
39190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39191         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39192         return ret_ref;
39193 }
39194 int64_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint64_t arg) {
39195         LDKNodeId arg_conv;
39196         arg_conv.inner = untag_ptr(arg);
39197         arg_conv.is_owned = ptr_is_owned(arg);
39198         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39199         arg_conv.is_owned = false;
39200         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
39201         return ret_conv;
39202 }
39203
39204 uint64_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint64_t orig) {
39205         LDKNodeId orig_conv;
39206         orig_conv.inner = untag_ptr(orig);
39207         orig_conv.is_owned = ptr_is_owned(orig);
39208         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39209         orig_conv.is_owned = false;
39210         LDKNodeId ret_var = NodeId_clone(&orig_conv);
39211         uint64_t ret_ref = 0;
39212         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39213         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39214         return ret_ref;
39215 }
39216
39217 uint64_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
39218         LDKPublicKey pubkey_ref;
39219         CHECK(pubkey->arr_len == 33);
39220         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
39221         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
39222         uint64_t ret_ref = 0;
39223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39224         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39225         return ret_ref;
39226 }
39227
39228 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint64_t this_arg) {
39229         LDKNodeId this_arg_conv;
39230         this_arg_conv.inner = untag_ptr(this_arg);
39231         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39233         this_arg_conv.is_owned = false;
39234         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
39235         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39236         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39237         return ret_arr;
39238 }
39239
39240 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint64_t o) {
39241         LDKNodeId o_conv;
39242         o_conv.inner = untag_ptr(o);
39243         o_conv.is_owned = ptr_is_owned(o);
39244         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39245         o_conv.is_owned = false;
39246         int64_t ret_conv = NodeId_hash(&o_conv);
39247         return ret_conv;
39248 }
39249
39250 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint64_t obj) {
39251         LDKNodeId obj_conv;
39252         obj_conv.inner = untag_ptr(obj);
39253         obj_conv.is_owned = ptr_is_owned(obj);
39254         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39255         obj_conv.is_owned = false;
39256         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
39257         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39258         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39259         CVec_u8Z_free(ret_var);
39260         return ret_arr;
39261 }
39262
39263 uint64_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
39264         LDKu8slice ser_ref;
39265         ser_ref.datalen = ser->arr_len;
39266         ser_ref.data = ser->elems;
39267         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
39268         *ret_conv = NodeId_read(ser_ref);
39269         FREE(ser);
39270         return tag_ptr(ret_conv, true);
39271 }
39272
39273 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint64_t this_obj) {
39274         LDKNetworkGraph this_obj_conv;
39275         this_obj_conv.inner = untag_ptr(this_obj);
39276         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39278         NetworkGraph_free(this_obj_conv);
39279 }
39280
39281 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint64_t this_obj) {
39282         LDKReadOnlyNetworkGraph this_obj_conv;
39283         this_obj_conv.inner = untag_ptr(this_obj);
39284         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39286         ReadOnlyNetworkGraph_free(this_obj_conv);
39287 }
39288
39289 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint64_t this_ptr) {
39290         if (!ptr_is_owned(this_ptr)) return;
39291         void* this_ptr_ptr = untag_ptr(this_ptr);
39292         CHECK_ACCESS(this_ptr_ptr);
39293         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
39294         FREE(untag_ptr(this_ptr));
39295         NetworkUpdate_free(this_ptr_conv);
39296 }
39297
39298 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
39299         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39300         *ret_copy = NetworkUpdate_clone(arg);
39301         uint64_t ret_ref = tag_ptr(ret_copy, true);
39302         return ret_ref;
39303 }
39304 int64_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint64_t arg) {
39305         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)untag_ptr(arg);
39306         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
39307         return ret_conv;
39308 }
39309
39310 uint64_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint64_t orig) {
39311         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)untag_ptr(orig);
39312         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39313         *ret_copy = NetworkUpdate_clone(orig_conv);
39314         uint64_t ret_ref = tag_ptr(ret_copy, true);
39315         return ret_ref;
39316 }
39317
39318 uint64_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint64_t msg) {
39319         LDKChannelUpdate msg_conv;
39320         msg_conv.inner = untag_ptr(msg);
39321         msg_conv.is_owned = ptr_is_owned(msg);
39322         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39323         msg_conv = ChannelUpdate_clone(&msg_conv);
39324         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39325         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
39326         uint64_t ret_ref = tag_ptr(ret_copy, true);
39327         return ret_ref;
39328 }
39329
39330 uint64_t  __attribute__((export_name("TS_NetworkUpdate_channel_failure"))) TS_NetworkUpdate_channel_failure(int64_t short_channel_id, jboolean is_permanent) {
39331         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39332         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
39333         uint64_t ret_ref = tag_ptr(ret_copy, true);
39334         return ret_ref;
39335 }
39336
39337 uint64_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
39338         LDKPublicKey node_id_ref;
39339         CHECK(node_id->arr_len == 33);
39340         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
39341         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39342         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
39343         uint64_t ret_ref = tag_ptr(ret_copy, true);
39344         return ret_ref;
39345 }
39346
39347 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint64_t obj) {
39348         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)untag_ptr(obj);
39349         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
39350         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39351         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39352         CVec_u8Z_free(ret_var);
39353         return ret_arr;
39354 }
39355
39356 uint64_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
39357         LDKu8slice ser_ref;
39358         ser_ref.datalen = ser->arr_len;
39359         ser_ref.data = ser->elems;
39360         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
39361         *ret_conv = NetworkUpdate_read(ser_ref);
39362         FREE(ser);
39363         return tag_ptr(ret_conv, true);
39364 }
39365
39366 void  __attribute__((export_name("TS_P2PGossipSync_free"))) TS_P2PGossipSync_free(uint64_t this_obj) {
39367         LDKP2PGossipSync this_obj_conv;
39368         this_obj_conv.inner = untag_ptr(this_obj);
39369         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39371         P2PGossipSync_free(this_obj_conv);
39372 }
39373
39374 uint64_t  __attribute__((export_name("TS_P2PGossipSync_new"))) TS_P2PGossipSync_new(uint64_t network_graph, uint64_t chain_access, uint64_t logger) {
39375         LDKNetworkGraph network_graph_conv;
39376         network_graph_conv.inner = untag_ptr(network_graph);
39377         network_graph_conv.is_owned = ptr_is_owned(network_graph);
39378         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
39379         network_graph_conv.is_owned = false;
39380         void* chain_access_ptr = untag_ptr(chain_access);
39381         CHECK_ACCESS(chain_access_ptr);
39382         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39383         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39384         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39385                 // Manually implement clone for Java trait instances
39386                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39387                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39388                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39389                 }
39390         }
39391         void* logger_ptr = untag_ptr(logger);
39392         CHECK_ACCESS(logger_ptr);
39393         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
39394         if (logger_conv.free == LDKLogger_JCalls_free) {
39395                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39396                 LDKLogger_JCalls_cloned(&logger_conv);
39397         }
39398         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
39399         uint64_t ret_ref = 0;
39400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39401         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39402         return ret_ref;
39403 }
39404
39405 void  __attribute__((export_name("TS_P2PGossipSync_add_chain_access"))) TS_P2PGossipSync_add_chain_access(uint64_t this_arg, uint64_t chain_access) {
39406         LDKP2PGossipSync this_arg_conv;
39407         this_arg_conv.inner = untag_ptr(this_arg);
39408         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39410         this_arg_conv.is_owned = false;
39411         void* chain_access_ptr = untag_ptr(chain_access);
39412         CHECK_ACCESS(chain_access_ptr);
39413         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39414         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39415         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39416                 // Manually implement clone for Java trait instances
39417                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39418                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39419                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39420                 }
39421         }
39422         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
39423 }
39424
39425 uint64_t  __attribute__((export_name("TS_NetworkGraph_as_EventHandler"))) TS_NetworkGraph_as_EventHandler(uint64_t this_arg) {
39426         LDKNetworkGraph this_arg_conv;
39427         this_arg_conv.inner = untag_ptr(this_arg);
39428         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39430         this_arg_conv.is_owned = false;
39431         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
39432         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
39433         return tag_ptr(ret_ret, true);
39434 }
39435
39436 uint64_t  __attribute__((export_name("TS_P2PGossipSync_as_RoutingMessageHandler"))) TS_P2PGossipSync_as_RoutingMessageHandler(uint64_t this_arg) {
39437         LDKP2PGossipSync this_arg_conv;
39438         this_arg_conv.inner = untag_ptr(this_arg);
39439         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39441         this_arg_conv.is_owned = false;
39442         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
39443         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
39444         return tag_ptr(ret_ret, true);
39445 }
39446
39447 uint64_t  __attribute__((export_name("TS_P2PGossipSync_as_MessageSendEventsProvider"))) TS_P2PGossipSync_as_MessageSendEventsProvider(uint64_t this_arg) {
39448         LDKP2PGossipSync this_arg_conv;
39449         this_arg_conv.inner = untag_ptr(this_arg);
39450         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39452         this_arg_conv.is_owned = false;
39453         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
39454         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
39455         return tag_ptr(ret_ret, true);
39456 }
39457
39458 void  __attribute__((export_name("TS_ChannelUpdateInfo_free"))) TS_ChannelUpdateInfo_free(uint64_t this_obj) {
39459         LDKChannelUpdateInfo this_obj_conv;
39460         this_obj_conv.inner = untag_ptr(this_obj);
39461         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39463         ChannelUpdateInfo_free(this_obj_conv);
39464 }
39465
39466 int32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update"))) TS_ChannelUpdateInfo_get_last_update(uint64_t this_ptr) {
39467         LDKChannelUpdateInfo this_ptr_conv;
39468         this_ptr_conv.inner = untag_ptr(this_ptr);
39469         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39471         this_ptr_conv.is_owned = false;
39472         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
39473         return ret_conv;
39474 }
39475
39476 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update"))) TS_ChannelUpdateInfo_set_last_update(uint64_t this_ptr, int32_t val) {
39477         LDKChannelUpdateInfo this_ptr_conv;
39478         this_ptr_conv.inner = untag_ptr(this_ptr);
39479         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39481         this_ptr_conv.is_owned = false;
39482         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
39483 }
39484
39485 jboolean  __attribute__((export_name("TS_ChannelUpdateInfo_get_enabled"))) TS_ChannelUpdateInfo_get_enabled(uint64_t this_ptr) {
39486         LDKChannelUpdateInfo this_ptr_conv;
39487         this_ptr_conv.inner = untag_ptr(this_ptr);
39488         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39490         this_ptr_conv.is_owned = false;
39491         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
39492         return ret_conv;
39493 }
39494
39495 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_enabled"))) TS_ChannelUpdateInfo_set_enabled(uint64_t this_ptr, jboolean val) {
39496         LDKChannelUpdateInfo this_ptr_conv;
39497         this_ptr_conv.inner = untag_ptr(this_ptr);
39498         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39500         this_ptr_conv.is_owned = false;
39501         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
39502 }
39503
39504 int16_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_cltv_expiry_delta"))) TS_ChannelUpdateInfo_get_cltv_expiry_delta(uint64_t this_ptr) {
39505         LDKChannelUpdateInfo this_ptr_conv;
39506         this_ptr_conv.inner = untag_ptr(this_ptr);
39507         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39509         this_ptr_conv.is_owned = false;
39510         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
39511         return ret_conv;
39512 }
39513
39514 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_cltv_expiry_delta"))) TS_ChannelUpdateInfo_set_cltv_expiry_delta(uint64_t this_ptr, int16_t val) {
39515         LDKChannelUpdateInfo this_ptr_conv;
39516         this_ptr_conv.inner = untag_ptr(this_ptr);
39517         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39519         this_ptr_conv.is_owned = false;
39520         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
39521 }
39522
39523 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_minimum_msat"))) TS_ChannelUpdateInfo_get_htlc_minimum_msat(uint64_t this_ptr) {
39524         LDKChannelUpdateInfo this_ptr_conv;
39525         this_ptr_conv.inner = untag_ptr(this_ptr);
39526         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39528         this_ptr_conv.is_owned = false;
39529         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
39530         return ret_conv;
39531 }
39532
39533 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_minimum_msat"))) TS_ChannelUpdateInfo_set_htlc_minimum_msat(uint64_t this_ptr, int64_t val) {
39534         LDKChannelUpdateInfo this_ptr_conv;
39535         this_ptr_conv.inner = untag_ptr(this_ptr);
39536         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39538         this_ptr_conv.is_owned = false;
39539         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
39540 }
39541
39542 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_maximum_msat"))) TS_ChannelUpdateInfo_get_htlc_maximum_msat(uint64_t this_ptr) {
39543         LDKChannelUpdateInfo this_ptr_conv;
39544         this_ptr_conv.inner = untag_ptr(this_ptr);
39545         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39547         this_ptr_conv.is_owned = false;
39548         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
39549         return ret_conv;
39550 }
39551
39552 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_maximum_msat"))) TS_ChannelUpdateInfo_set_htlc_maximum_msat(uint64_t this_ptr, int64_t val) {
39553         LDKChannelUpdateInfo this_ptr_conv;
39554         this_ptr_conv.inner = untag_ptr(this_ptr);
39555         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39557         this_ptr_conv.is_owned = false;
39558         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
39559 }
39560
39561 uint64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_fees"))) TS_ChannelUpdateInfo_get_fees(uint64_t this_ptr) {
39562         LDKChannelUpdateInfo this_ptr_conv;
39563         this_ptr_conv.inner = untag_ptr(this_ptr);
39564         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39566         this_ptr_conv.is_owned = false;
39567         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
39568         uint64_t ret_ref = 0;
39569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39570         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39571         return ret_ref;
39572 }
39573
39574 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_fees"))) TS_ChannelUpdateInfo_set_fees(uint64_t this_ptr, uint64_t val) {
39575         LDKChannelUpdateInfo this_ptr_conv;
39576         this_ptr_conv.inner = untag_ptr(this_ptr);
39577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39579         this_ptr_conv.is_owned = false;
39580         LDKRoutingFees val_conv;
39581         val_conv.inner = untag_ptr(val);
39582         val_conv.is_owned = ptr_is_owned(val);
39583         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39584         val_conv = RoutingFees_clone(&val_conv);
39585         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
39586 }
39587
39588 uint64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update_message"))) TS_ChannelUpdateInfo_get_last_update_message(uint64_t this_ptr) {
39589         LDKChannelUpdateInfo this_ptr_conv;
39590         this_ptr_conv.inner = untag_ptr(this_ptr);
39591         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39593         this_ptr_conv.is_owned = false;
39594         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
39595         uint64_t ret_ref = 0;
39596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39597         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39598         return ret_ref;
39599 }
39600
39601 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update_message"))) TS_ChannelUpdateInfo_set_last_update_message(uint64_t this_ptr, uint64_t val) {
39602         LDKChannelUpdateInfo this_ptr_conv;
39603         this_ptr_conv.inner = untag_ptr(this_ptr);
39604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39606         this_ptr_conv.is_owned = false;
39607         LDKChannelUpdate val_conv;
39608         val_conv.inner = untag_ptr(val);
39609         val_conv.is_owned = ptr_is_owned(val);
39610         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39611         val_conv = ChannelUpdate_clone(&val_conv);
39612         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
39613 }
39614
39615 uint64_t  __attribute__((export_name("TS_ChannelUpdateInfo_new"))) TS_ChannelUpdateInfo_new(int32_t last_update_arg, jboolean enabled_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, uint64_t fees_arg, uint64_t last_update_message_arg) {
39616         LDKRoutingFees fees_arg_conv;
39617         fees_arg_conv.inner = untag_ptr(fees_arg);
39618         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
39619         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
39620         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
39621         LDKChannelUpdate last_update_message_arg_conv;
39622         last_update_message_arg_conv.inner = untag_ptr(last_update_message_arg);
39623         last_update_message_arg_conv.is_owned = ptr_is_owned(last_update_message_arg);
39624         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
39625         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
39626         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fees_arg_conv, last_update_message_arg_conv);
39627         uint64_t ret_ref = 0;
39628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39629         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39630         return ret_ref;
39631 }
39632
39633 static inline uint64_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
39634         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
39635         uint64_t ret_ref = 0;
39636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39637         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39638         return ret_ref;
39639 }
39640 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone_ptr"))) TS_ChannelUpdateInfo_clone_ptr(uint64_t arg) {
39641         LDKChannelUpdateInfo arg_conv;
39642         arg_conv.inner = untag_ptr(arg);
39643         arg_conv.is_owned = ptr_is_owned(arg);
39644         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39645         arg_conv.is_owned = false;
39646         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
39647         return ret_conv;
39648 }
39649
39650 uint64_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone"))) TS_ChannelUpdateInfo_clone(uint64_t orig) {
39651         LDKChannelUpdateInfo orig_conv;
39652         orig_conv.inner = untag_ptr(orig);
39653         orig_conv.is_owned = ptr_is_owned(orig);
39654         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39655         orig_conv.is_owned = false;
39656         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
39657         uint64_t ret_ref = 0;
39658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39659         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39660         return ret_ref;
39661 }
39662
39663 int8_tArray  __attribute__((export_name("TS_ChannelUpdateInfo_write"))) TS_ChannelUpdateInfo_write(uint64_t obj) {
39664         LDKChannelUpdateInfo obj_conv;
39665         obj_conv.inner = untag_ptr(obj);
39666         obj_conv.is_owned = ptr_is_owned(obj);
39667         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39668         obj_conv.is_owned = false;
39669         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
39670         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39671         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39672         CVec_u8Z_free(ret_var);
39673         return ret_arr;
39674 }
39675
39676 uint64_t  __attribute__((export_name("TS_ChannelUpdateInfo_read"))) TS_ChannelUpdateInfo_read(int8_tArray ser) {
39677         LDKu8slice ser_ref;
39678         ser_ref.datalen = ser->arr_len;
39679         ser_ref.data = ser->elems;
39680         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
39681         *ret_conv = ChannelUpdateInfo_read(ser_ref);
39682         FREE(ser);
39683         return tag_ptr(ret_conv, true);
39684 }
39685
39686 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint64_t this_obj) {
39687         LDKChannelInfo this_obj_conv;
39688         this_obj_conv.inner = untag_ptr(this_obj);
39689         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39691         ChannelInfo_free(this_obj_conv);
39692 }
39693
39694 uint64_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint64_t this_ptr) {
39695         LDKChannelInfo this_ptr_conv;
39696         this_ptr_conv.inner = untag_ptr(this_ptr);
39697         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39699         this_ptr_conv.is_owned = false;
39700         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
39701         uint64_t ret_ref = 0;
39702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39703         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39704         return ret_ref;
39705 }
39706
39707 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint64_t this_ptr, uint64_t val) {
39708         LDKChannelInfo this_ptr_conv;
39709         this_ptr_conv.inner = untag_ptr(this_ptr);
39710         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39712         this_ptr_conv.is_owned = false;
39713         LDKChannelFeatures val_conv;
39714         val_conv.inner = untag_ptr(val);
39715         val_conv.is_owned = ptr_is_owned(val);
39716         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39717         val_conv = ChannelFeatures_clone(&val_conv);
39718         ChannelInfo_set_features(&this_ptr_conv, val_conv);
39719 }
39720
39721 uint64_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint64_t this_ptr) {
39722         LDKChannelInfo this_ptr_conv;
39723         this_ptr_conv.inner = untag_ptr(this_ptr);
39724         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39726         this_ptr_conv.is_owned = false;
39727         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
39728         uint64_t ret_ref = 0;
39729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39730         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39731         return ret_ref;
39732 }
39733
39734 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint64_t this_ptr, uint64_t val) {
39735         LDKChannelInfo this_ptr_conv;
39736         this_ptr_conv.inner = untag_ptr(this_ptr);
39737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39739         this_ptr_conv.is_owned = false;
39740         LDKNodeId val_conv;
39741         val_conv.inner = untag_ptr(val);
39742         val_conv.is_owned = ptr_is_owned(val);
39743         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39744         val_conv = NodeId_clone(&val_conv);
39745         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
39746 }
39747
39748 uint64_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint64_t this_ptr) {
39749         LDKChannelInfo this_ptr_conv;
39750         this_ptr_conv.inner = untag_ptr(this_ptr);
39751         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39753         this_ptr_conv.is_owned = false;
39754         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
39755         uint64_t ret_ref = 0;
39756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39757         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39758         return ret_ref;
39759 }
39760
39761 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint64_t this_ptr, uint64_t val) {
39762         LDKChannelInfo this_ptr_conv;
39763         this_ptr_conv.inner = untag_ptr(this_ptr);
39764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39766         this_ptr_conv.is_owned = false;
39767         LDKChannelUpdateInfo val_conv;
39768         val_conv.inner = untag_ptr(val);
39769         val_conv.is_owned = ptr_is_owned(val);
39770         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39771         val_conv = ChannelUpdateInfo_clone(&val_conv);
39772         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
39773 }
39774
39775 uint64_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint64_t this_ptr) {
39776         LDKChannelInfo this_ptr_conv;
39777         this_ptr_conv.inner = untag_ptr(this_ptr);
39778         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39780         this_ptr_conv.is_owned = false;
39781         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
39782         uint64_t ret_ref = 0;
39783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39784         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39785         return ret_ref;
39786 }
39787
39788 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint64_t this_ptr, uint64_t val) {
39789         LDKChannelInfo this_ptr_conv;
39790         this_ptr_conv.inner = untag_ptr(this_ptr);
39791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39793         this_ptr_conv.is_owned = false;
39794         LDKNodeId val_conv;
39795         val_conv.inner = untag_ptr(val);
39796         val_conv.is_owned = ptr_is_owned(val);
39797         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39798         val_conv = NodeId_clone(&val_conv);
39799         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
39800 }
39801
39802 uint64_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint64_t this_ptr) {
39803         LDKChannelInfo this_ptr_conv;
39804         this_ptr_conv.inner = untag_ptr(this_ptr);
39805         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39807         this_ptr_conv.is_owned = false;
39808         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
39809         uint64_t ret_ref = 0;
39810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39811         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39812         return ret_ref;
39813 }
39814
39815 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint64_t this_ptr, uint64_t val) {
39816         LDKChannelInfo this_ptr_conv;
39817         this_ptr_conv.inner = untag_ptr(this_ptr);
39818         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39820         this_ptr_conv.is_owned = false;
39821         LDKChannelUpdateInfo val_conv;
39822         val_conv.inner = untag_ptr(val);
39823         val_conv.is_owned = ptr_is_owned(val);
39824         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39825         val_conv = ChannelUpdateInfo_clone(&val_conv);
39826         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
39827 }
39828
39829 uint64_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint64_t this_ptr) {
39830         LDKChannelInfo this_ptr_conv;
39831         this_ptr_conv.inner = untag_ptr(this_ptr);
39832         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39834         this_ptr_conv.is_owned = false;
39835         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39836         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
39837         uint64_t ret_ref = tag_ptr(ret_copy, true);
39838         return ret_ref;
39839 }
39840
39841 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint64_t this_ptr, uint64_t val) {
39842         LDKChannelInfo this_ptr_conv;
39843         this_ptr_conv.inner = untag_ptr(this_ptr);
39844         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39846         this_ptr_conv.is_owned = false;
39847         void* val_ptr = untag_ptr(val);
39848         CHECK_ACCESS(val_ptr);
39849         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
39850         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
39851         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
39852 }
39853
39854 uint64_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint64_t this_ptr) {
39855         LDKChannelInfo this_ptr_conv;
39856         this_ptr_conv.inner = untag_ptr(this_ptr);
39857         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39859         this_ptr_conv.is_owned = false;
39860         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
39861         uint64_t ret_ref = 0;
39862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39863         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39864         return ret_ref;
39865 }
39866
39867 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint64_t this_ptr, uint64_t val) {
39868         LDKChannelInfo this_ptr_conv;
39869         this_ptr_conv.inner = untag_ptr(this_ptr);
39870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39872         this_ptr_conv.is_owned = false;
39873         LDKChannelAnnouncement val_conv;
39874         val_conv.inner = untag_ptr(val);
39875         val_conv.is_owned = ptr_is_owned(val);
39876         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39877         val_conv = ChannelAnnouncement_clone(&val_conv);
39878         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
39879 }
39880
39881 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
39882         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
39883         uint64_t ret_ref = 0;
39884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39885         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39886         return ret_ref;
39887 }
39888 int64_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint64_t arg) {
39889         LDKChannelInfo arg_conv;
39890         arg_conv.inner = untag_ptr(arg);
39891         arg_conv.is_owned = ptr_is_owned(arg);
39892         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39893         arg_conv.is_owned = false;
39894         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
39895         return ret_conv;
39896 }
39897
39898 uint64_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint64_t orig) {
39899         LDKChannelInfo orig_conv;
39900         orig_conv.inner = untag_ptr(orig);
39901         orig_conv.is_owned = ptr_is_owned(orig);
39902         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39903         orig_conv.is_owned = false;
39904         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
39905         uint64_t ret_ref = 0;
39906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39907         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39908         return ret_ref;
39909 }
39910
39911 uint64_t  __attribute__((export_name("TS_ChannelInfo_get_directional_info"))) TS_ChannelInfo_get_directional_info(uint64_t this_arg, int8_t channel_flags) {
39912         LDKChannelInfo this_arg_conv;
39913         this_arg_conv.inner = untag_ptr(this_arg);
39914         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39916         this_arg_conv.is_owned = false;
39917         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
39918         uint64_t ret_ref = 0;
39919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39920         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39921         return ret_ref;
39922 }
39923
39924 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint64_t obj) {
39925         LDKChannelInfo obj_conv;
39926         obj_conv.inner = untag_ptr(obj);
39927         obj_conv.is_owned = ptr_is_owned(obj);
39928         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39929         obj_conv.is_owned = false;
39930         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
39931         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39932         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39933         CVec_u8Z_free(ret_var);
39934         return ret_arr;
39935 }
39936
39937 uint64_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
39938         LDKu8slice ser_ref;
39939         ser_ref.datalen = ser->arr_len;
39940         ser_ref.data = ser->elems;
39941         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
39942         *ret_conv = ChannelInfo_read(ser_ref);
39943         FREE(ser);
39944         return tag_ptr(ret_conv, true);
39945 }
39946
39947 void  __attribute__((export_name("TS_DirectedChannelInfo_free"))) TS_DirectedChannelInfo_free(uint64_t this_obj) {
39948         LDKDirectedChannelInfo this_obj_conv;
39949         this_obj_conv.inner = untag_ptr(this_obj);
39950         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39952         DirectedChannelInfo_free(this_obj_conv);
39953 }
39954
39955 static inline uint64_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
39956         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
39957         uint64_t ret_ref = 0;
39958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39959         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39960         return ret_ref;
39961 }
39962 int64_t  __attribute__((export_name("TS_DirectedChannelInfo_clone_ptr"))) TS_DirectedChannelInfo_clone_ptr(uint64_t arg) {
39963         LDKDirectedChannelInfo arg_conv;
39964         arg_conv.inner = untag_ptr(arg);
39965         arg_conv.is_owned = ptr_is_owned(arg);
39966         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39967         arg_conv.is_owned = false;
39968         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
39969         return ret_conv;
39970 }
39971
39972 uint64_t  __attribute__((export_name("TS_DirectedChannelInfo_clone"))) TS_DirectedChannelInfo_clone(uint64_t orig) {
39973         LDKDirectedChannelInfo orig_conv;
39974         orig_conv.inner = untag_ptr(orig);
39975         orig_conv.is_owned = ptr_is_owned(orig);
39976         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39977         orig_conv.is_owned = false;
39978         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
39979         uint64_t ret_ref = 0;
39980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39981         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39982         return ret_ref;
39983 }
39984
39985 uint64_t  __attribute__((export_name("TS_DirectedChannelInfo_channel"))) TS_DirectedChannelInfo_channel(uint64_t this_arg) {
39986         LDKDirectedChannelInfo this_arg_conv;
39987         this_arg_conv.inner = untag_ptr(this_arg);
39988         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39990         this_arg_conv.is_owned = false;
39991         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
39992         uint64_t ret_ref = 0;
39993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39994         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39995         return ret_ref;
39996 }
39997
39998 uint64_t  __attribute__((export_name("TS_DirectedChannelInfo_direction"))) TS_DirectedChannelInfo_direction(uint64_t this_arg) {
39999         LDKDirectedChannelInfo this_arg_conv;
40000         this_arg_conv.inner = untag_ptr(this_arg);
40001         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40003         this_arg_conv.is_owned = false;
40004         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
40005         uint64_t ret_ref = 0;
40006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40007         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40008         return ret_ref;
40009 }
40010
40011 int64_t  __attribute__((export_name("TS_DirectedChannelInfo_htlc_maximum_msat"))) TS_DirectedChannelInfo_htlc_maximum_msat(uint64_t this_arg) {
40012         LDKDirectedChannelInfo this_arg_conv;
40013         this_arg_conv.inner = untag_ptr(this_arg);
40014         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40016         this_arg_conv.is_owned = false;
40017         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
40018         return ret_conv;
40019 }
40020
40021 uint64_t  __attribute__((export_name("TS_DirectedChannelInfo_effective_capacity"))) TS_DirectedChannelInfo_effective_capacity(uint64_t this_arg) {
40022         LDKDirectedChannelInfo this_arg_conv;
40023         this_arg_conv.inner = untag_ptr(this_arg);
40024         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40026         this_arg_conv.is_owned = false;
40027         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40028         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
40029         uint64_t ret_ref = tag_ptr(ret_copy, true);
40030         return ret_ref;
40031 }
40032
40033 void  __attribute__((export_name("TS_EffectiveCapacity_free"))) TS_EffectiveCapacity_free(uint64_t this_ptr) {
40034         if (!ptr_is_owned(this_ptr)) return;
40035         void* this_ptr_ptr = untag_ptr(this_ptr);
40036         CHECK_ACCESS(this_ptr_ptr);
40037         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
40038         FREE(untag_ptr(this_ptr));
40039         EffectiveCapacity_free(this_ptr_conv);
40040 }
40041
40042 static inline uint64_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
40043         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40044         *ret_copy = EffectiveCapacity_clone(arg);
40045         uint64_t ret_ref = tag_ptr(ret_copy, true);
40046         return ret_ref;
40047 }
40048 int64_t  __attribute__((export_name("TS_EffectiveCapacity_clone_ptr"))) TS_EffectiveCapacity_clone_ptr(uint64_t arg) {
40049         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)untag_ptr(arg);
40050         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
40051         return ret_conv;
40052 }
40053
40054 uint64_t  __attribute__((export_name("TS_EffectiveCapacity_clone"))) TS_EffectiveCapacity_clone(uint64_t orig) {
40055         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)untag_ptr(orig);
40056         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40057         *ret_copy = EffectiveCapacity_clone(orig_conv);
40058         uint64_t ret_ref = tag_ptr(ret_copy, true);
40059         return ret_ref;
40060 }
40061
40062 uint64_t  __attribute__((export_name("TS_EffectiveCapacity_exact_liquidity"))) TS_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
40063         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40064         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
40065         uint64_t ret_ref = tag_ptr(ret_copy, true);
40066         return ret_ref;
40067 }
40068
40069 uint64_t  __attribute__((export_name("TS_EffectiveCapacity_maximum_htlc"))) TS_EffectiveCapacity_maximum_htlc(int64_t amount_msat) {
40070         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40071         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
40072         uint64_t ret_ref = tag_ptr(ret_copy, true);
40073         return ret_ref;
40074 }
40075
40076 uint64_t  __attribute__((export_name("TS_EffectiveCapacity_total"))) TS_EffectiveCapacity_total(int64_t capacity_msat, uint64_t htlc_maximum_msat) {
40077         void* htlc_maximum_msat_ptr = untag_ptr(htlc_maximum_msat);
40078         CHECK_ACCESS(htlc_maximum_msat_ptr);
40079         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
40080         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat));
40081         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40082         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
40083         uint64_t ret_ref = tag_ptr(ret_copy, true);
40084         return ret_ref;
40085 }
40086
40087 uint64_t  __attribute__((export_name("TS_EffectiveCapacity_infinite"))) TS_EffectiveCapacity_infinite() {
40088         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40089         *ret_copy = EffectiveCapacity_infinite();
40090         uint64_t ret_ref = tag_ptr(ret_copy, true);
40091         return ret_ref;
40092 }
40093
40094 uint64_t  __attribute__((export_name("TS_EffectiveCapacity_unknown"))) TS_EffectiveCapacity_unknown() {
40095         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40096         *ret_copy = EffectiveCapacity_unknown();
40097         uint64_t ret_ref = tag_ptr(ret_copy, true);
40098         return ret_ref;
40099 }
40100
40101 int64_t  __attribute__((export_name("TS_EffectiveCapacity_as_msat"))) TS_EffectiveCapacity_as_msat(uint64_t this_arg) {
40102         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)untag_ptr(this_arg);
40103         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
40104         return ret_conv;
40105 }
40106
40107 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint64_t this_obj) {
40108         LDKRoutingFees this_obj_conv;
40109         this_obj_conv.inner = untag_ptr(this_obj);
40110         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40112         RoutingFees_free(this_obj_conv);
40113 }
40114
40115 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint64_t this_ptr) {
40116         LDKRoutingFees this_ptr_conv;
40117         this_ptr_conv.inner = untag_ptr(this_ptr);
40118         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40120         this_ptr_conv.is_owned = false;
40121         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
40122         return ret_conv;
40123 }
40124
40125 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint64_t this_ptr, int32_t val) {
40126         LDKRoutingFees this_ptr_conv;
40127         this_ptr_conv.inner = untag_ptr(this_ptr);
40128         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40130         this_ptr_conv.is_owned = false;
40131         RoutingFees_set_base_msat(&this_ptr_conv, val);
40132 }
40133
40134 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint64_t this_ptr) {
40135         LDKRoutingFees this_ptr_conv;
40136         this_ptr_conv.inner = untag_ptr(this_ptr);
40137         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40139         this_ptr_conv.is_owned = false;
40140         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
40141         return ret_conv;
40142 }
40143
40144 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint64_t this_ptr, int32_t val) {
40145         LDKRoutingFees this_ptr_conv;
40146         this_ptr_conv.inner = untag_ptr(this_ptr);
40147         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40149         this_ptr_conv.is_owned = false;
40150         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
40151 }
40152
40153 uint64_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
40154         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
40155         uint64_t ret_ref = 0;
40156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40157         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40158         return ret_ref;
40159 }
40160
40161 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint64_t a, uint64_t b) {
40162         LDKRoutingFees a_conv;
40163         a_conv.inner = untag_ptr(a);
40164         a_conv.is_owned = ptr_is_owned(a);
40165         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40166         a_conv.is_owned = false;
40167         LDKRoutingFees b_conv;
40168         b_conv.inner = untag_ptr(b);
40169         b_conv.is_owned = ptr_is_owned(b);
40170         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40171         b_conv.is_owned = false;
40172         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
40173         return ret_conv;
40174 }
40175
40176 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
40177         LDKRoutingFees ret_var = RoutingFees_clone(arg);
40178         uint64_t ret_ref = 0;
40179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40180         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40181         return ret_ref;
40182 }
40183 int64_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint64_t arg) {
40184         LDKRoutingFees arg_conv;
40185         arg_conv.inner = untag_ptr(arg);
40186         arg_conv.is_owned = ptr_is_owned(arg);
40187         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40188         arg_conv.is_owned = false;
40189         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
40190         return ret_conv;
40191 }
40192
40193 uint64_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint64_t orig) {
40194         LDKRoutingFees orig_conv;
40195         orig_conv.inner = untag_ptr(orig);
40196         orig_conv.is_owned = ptr_is_owned(orig);
40197         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40198         orig_conv.is_owned = false;
40199         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
40200         uint64_t ret_ref = 0;
40201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40202         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40203         return ret_ref;
40204 }
40205
40206 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint64_t o) {
40207         LDKRoutingFees o_conv;
40208         o_conv.inner = untag_ptr(o);
40209         o_conv.is_owned = ptr_is_owned(o);
40210         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40211         o_conv.is_owned = false;
40212         int64_t ret_conv = RoutingFees_hash(&o_conv);
40213         return ret_conv;
40214 }
40215
40216 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint64_t obj) {
40217         LDKRoutingFees obj_conv;
40218         obj_conv.inner = untag_ptr(obj);
40219         obj_conv.is_owned = ptr_is_owned(obj);
40220         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40221         obj_conv.is_owned = false;
40222         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
40223         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40224         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40225         CVec_u8Z_free(ret_var);
40226         return ret_arr;
40227 }
40228
40229 uint64_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
40230         LDKu8slice ser_ref;
40231         ser_ref.datalen = ser->arr_len;
40232         ser_ref.data = ser->elems;
40233         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
40234         *ret_conv = RoutingFees_read(ser_ref);
40235         FREE(ser);
40236         return tag_ptr(ret_conv, true);
40237 }
40238
40239 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint64_t this_obj) {
40240         LDKNodeAnnouncementInfo this_obj_conv;
40241         this_obj_conv.inner = untag_ptr(this_obj);
40242         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40244         NodeAnnouncementInfo_free(this_obj_conv);
40245 }
40246
40247 uint64_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint64_t this_ptr) {
40248         LDKNodeAnnouncementInfo this_ptr_conv;
40249         this_ptr_conv.inner = untag_ptr(this_ptr);
40250         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40252         this_ptr_conv.is_owned = false;
40253         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
40254         uint64_t ret_ref = 0;
40255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40256         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40257         return ret_ref;
40258 }
40259
40260 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint64_t this_ptr, uint64_t val) {
40261         LDKNodeAnnouncementInfo this_ptr_conv;
40262         this_ptr_conv.inner = untag_ptr(this_ptr);
40263         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40265         this_ptr_conv.is_owned = false;
40266         LDKNodeFeatures val_conv;
40267         val_conv.inner = untag_ptr(val);
40268         val_conv.is_owned = ptr_is_owned(val);
40269         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40270         val_conv = NodeFeatures_clone(&val_conv);
40271         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
40272 }
40273
40274 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint64_t this_ptr) {
40275         LDKNodeAnnouncementInfo this_ptr_conv;
40276         this_ptr_conv.inner = untag_ptr(this_ptr);
40277         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40279         this_ptr_conv.is_owned = false;
40280         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
40281         return ret_conv;
40282 }
40283
40284 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint64_t this_ptr, int32_t val) {
40285         LDKNodeAnnouncementInfo this_ptr_conv;
40286         this_ptr_conv.inner = untag_ptr(this_ptr);
40287         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40289         this_ptr_conv.is_owned = false;
40290         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
40291 }
40292
40293 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint64_t this_ptr) {
40294         LDKNodeAnnouncementInfo this_ptr_conv;
40295         this_ptr_conv.inner = untag_ptr(this_ptr);
40296         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40298         this_ptr_conv.is_owned = false;
40299         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
40300         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
40301         return ret_arr;
40302 }
40303
40304 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint64_t this_ptr, int8_tArray val) {
40305         LDKNodeAnnouncementInfo this_ptr_conv;
40306         this_ptr_conv.inner = untag_ptr(this_ptr);
40307         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40309         this_ptr_conv.is_owned = false;
40310         LDKThreeBytes val_ref;
40311         CHECK(val->arr_len == 3);
40312         memcpy(val_ref.data, val->elems, 3); FREE(val);
40313         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
40314 }
40315
40316 uint64_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint64_t this_ptr) {
40317         LDKNodeAnnouncementInfo this_ptr_conv;
40318         this_ptr_conv.inner = untag_ptr(this_ptr);
40319         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40321         this_ptr_conv.is_owned = false;
40322         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
40323         uint64_t ret_ref = 0;
40324         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40325         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40326         return ret_ref;
40327 }
40328
40329 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint64_t this_ptr, uint64_t val) {
40330         LDKNodeAnnouncementInfo this_ptr_conv;
40331         this_ptr_conv.inner = untag_ptr(this_ptr);
40332         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40334         this_ptr_conv.is_owned = false;
40335         LDKNodeAlias val_conv;
40336         val_conv.inner = untag_ptr(val);
40337         val_conv.is_owned = ptr_is_owned(val);
40338         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40339         val_conv = NodeAlias_clone(&val_conv);
40340         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
40341 }
40342
40343 uint64_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_addresses"))) TS_NodeAnnouncementInfo_get_addresses(uint64_t this_ptr) {
40344         LDKNodeAnnouncementInfo this_ptr_conv;
40345         this_ptr_conv.inner = untag_ptr(this_ptr);
40346         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40348         this_ptr_conv.is_owned = false;
40349         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_get_addresses(&this_ptr_conv);
40350         uint64_tArray ret_arr = NULL;
40351         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
40352         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
40353         for (size_t m = 0; m < ret_var.datalen; m++) {
40354                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
40355                 *ret_conv_12_copy = ret_var.data[m];
40356                 uint64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
40357                 ret_arr_ptr[m] = ret_conv_12_ref;
40358         }
40359         
40360         FREE(ret_var.data);
40361         return ret_arr;
40362 }
40363
40364 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint64_t this_ptr, uint64_tArray val) {
40365         LDKNodeAnnouncementInfo this_ptr_conv;
40366         this_ptr_conv.inner = untag_ptr(this_ptr);
40367         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40369         this_ptr_conv.is_owned = false;
40370         LDKCVec_NetAddressZ val_constr;
40371         val_constr.datalen = val->arr_len;
40372         if (val_constr.datalen > 0)
40373                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40374         else
40375                 val_constr.data = NULL;
40376         uint64_t* val_vals = val->elems;
40377         for (size_t m = 0; m < val_constr.datalen; m++) {
40378                 uint64_t val_conv_12 = val_vals[m];
40379                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
40380                 CHECK_ACCESS(val_conv_12_ptr);
40381                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
40382                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
40383                 val_constr.data[m] = val_conv_12_conv;
40384         }
40385         FREE(val);
40386         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
40387 }
40388
40389 uint64_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint64_t this_ptr) {
40390         LDKNodeAnnouncementInfo this_ptr_conv;
40391         this_ptr_conv.inner = untag_ptr(this_ptr);
40392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40394         this_ptr_conv.is_owned = false;
40395         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
40396         uint64_t ret_ref = 0;
40397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40398         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40399         return ret_ref;
40400 }
40401
40402 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint64_t this_ptr, uint64_t val) {
40403         LDKNodeAnnouncementInfo this_ptr_conv;
40404         this_ptr_conv.inner = untag_ptr(this_ptr);
40405         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40407         this_ptr_conv.is_owned = false;
40408         LDKNodeAnnouncement val_conv;
40409         val_conv.inner = untag_ptr(val);
40410         val_conv.is_owned = ptr_is_owned(val);
40411         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40412         val_conv = NodeAnnouncement_clone(&val_conv);
40413         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
40414 }
40415
40416 uint64_t  __attribute__((export_name("TS_NodeAnnouncementInfo_new"))) TS_NodeAnnouncementInfo_new(uint64_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, uint64_t alias_arg, uint64_tArray addresses_arg, uint64_t announcement_message_arg) {
40417         LDKNodeFeatures features_arg_conv;
40418         features_arg_conv.inner = untag_ptr(features_arg);
40419         features_arg_conv.is_owned = ptr_is_owned(features_arg);
40420         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
40421         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
40422         LDKThreeBytes rgb_arg_ref;
40423         CHECK(rgb_arg->arr_len == 3);
40424         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
40425         LDKNodeAlias alias_arg_conv;
40426         alias_arg_conv.inner = untag_ptr(alias_arg);
40427         alias_arg_conv.is_owned = ptr_is_owned(alias_arg);
40428         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
40429         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
40430         LDKCVec_NetAddressZ addresses_arg_constr;
40431         addresses_arg_constr.datalen = addresses_arg->arr_len;
40432         if (addresses_arg_constr.datalen > 0)
40433                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40434         else
40435                 addresses_arg_constr.data = NULL;
40436         uint64_t* addresses_arg_vals = addresses_arg->elems;
40437         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
40438                 uint64_t addresses_arg_conv_12 = addresses_arg_vals[m];
40439                 void* addresses_arg_conv_12_ptr = untag_ptr(addresses_arg_conv_12);
40440                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
40441                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
40442                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
40443         }
40444         FREE(addresses_arg);
40445         LDKNodeAnnouncement announcement_message_arg_conv;
40446         announcement_message_arg_conv.inner = untag_ptr(announcement_message_arg);
40447         announcement_message_arg_conv.is_owned = ptr_is_owned(announcement_message_arg);
40448         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
40449         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
40450         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
40451         uint64_t ret_ref = 0;
40452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40453         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40454         return ret_ref;
40455 }
40456
40457 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
40458         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
40459         uint64_t ret_ref = 0;
40460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40461         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40462         return ret_ref;
40463 }
40464 int64_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint64_t arg) {
40465         LDKNodeAnnouncementInfo arg_conv;
40466         arg_conv.inner = untag_ptr(arg);
40467         arg_conv.is_owned = ptr_is_owned(arg);
40468         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40469         arg_conv.is_owned = false;
40470         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
40471         return ret_conv;
40472 }
40473
40474 uint64_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint64_t orig) {
40475         LDKNodeAnnouncementInfo orig_conv;
40476         orig_conv.inner = untag_ptr(orig);
40477         orig_conv.is_owned = ptr_is_owned(orig);
40478         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40479         orig_conv.is_owned = false;
40480         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
40481         uint64_t ret_ref = 0;
40482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40483         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40484         return ret_ref;
40485 }
40486
40487 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint64_t obj) {
40488         LDKNodeAnnouncementInfo obj_conv;
40489         obj_conv.inner = untag_ptr(obj);
40490         obj_conv.is_owned = ptr_is_owned(obj);
40491         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40492         obj_conv.is_owned = false;
40493         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
40494         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40495         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40496         CVec_u8Z_free(ret_var);
40497         return ret_arr;
40498 }
40499
40500 uint64_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
40501         LDKu8slice ser_ref;
40502         ser_ref.datalen = ser->arr_len;
40503         ser_ref.data = ser->elems;
40504         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
40505         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
40506         FREE(ser);
40507         return tag_ptr(ret_conv, true);
40508 }
40509
40510 void  __attribute__((export_name("TS_NodeAlias_free"))) TS_NodeAlias_free(uint64_t this_obj) {
40511         LDKNodeAlias this_obj_conv;
40512         this_obj_conv.inner = untag_ptr(this_obj);
40513         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40515         NodeAlias_free(this_obj_conv);
40516 }
40517
40518 int8_tArray  __attribute__((export_name("TS_NodeAlias_get_a"))) TS_NodeAlias_get_a(uint64_t this_ptr) {
40519         LDKNodeAlias this_ptr_conv;
40520         this_ptr_conv.inner = untag_ptr(this_ptr);
40521         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40523         this_ptr_conv.is_owned = false;
40524         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40525         memcpy(ret_arr->elems, *NodeAlias_get_a(&this_ptr_conv), 32);
40526         return ret_arr;
40527 }
40528
40529 void  __attribute__((export_name("TS_NodeAlias_set_a"))) TS_NodeAlias_set_a(uint64_t this_ptr, int8_tArray val) {
40530         LDKNodeAlias this_ptr_conv;
40531         this_ptr_conv.inner = untag_ptr(this_ptr);
40532         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40534         this_ptr_conv.is_owned = false;
40535         LDKThirtyTwoBytes val_ref;
40536         CHECK(val->arr_len == 32);
40537         memcpy(val_ref.data, val->elems, 32); FREE(val);
40538         NodeAlias_set_a(&this_ptr_conv, val_ref);
40539 }
40540
40541 uint64_t  __attribute__((export_name("TS_NodeAlias_new"))) TS_NodeAlias_new(int8_tArray a_arg) {
40542         LDKThirtyTwoBytes a_arg_ref;
40543         CHECK(a_arg->arr_len == 32);
40544         memcpy(a_arg_ref.data, a_arg->elems, 32); FREE(a_arg);
40545         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
40546         uint64_t ret_ref = 0;
40547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40548         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40549         return ret_ref;
40550 }
40551
40552 static inline uint64_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
40553         LDKNodeAlias ret_var = NodeAlias_clone(arg);
40554         uint64_t ret_ref = 0;
40555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40556         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40557         return ret_ref;
40558 }
40559 int64_t  __attribute__((export_name("TS_NodeAlias_clone_ptr"))) TS_NodeAlias_clone_ptr(uint64_t arg) {
40560         LDKNodeAlias arg_conv;
40561         arg_conv.inner = untag_ptr(arg);
40562         arg_conv.is_owned = ptr_is_owned(arg);
40563         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40564         arg_conv.is_owned = false;
40565         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
40566         return ret_conv;
40567 }
40568
40569 uint64_t  __attribute__((export_name("TS_NodeAlias_clone"))) TS_NodeAlias_clone(uint64_t orig) {
40570         LDKNodeAlias orig_conv;
40571         orig_conv.inner = untag_ptr(orig);
40572         orig_conv.is_owned = ptr_is_owned(orig);
40573         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40574         orig_conv.is_owned = false;
40575         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
40576         uint64_t ret_ref = 0;
40577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40578         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40579         return ret_ref;
40580 }
40581
40582 int8_tArray  __attribute__((export_name("TS_NodeAlias_write"))) TS_NodeAlias_write(uint64_t obj) {
40583         LDKNodeAlias obj_conv;
40584         obj_conv.inner = untag_ptr(obj);
40585         obj_conv.is_owned = ptr_is_owned(obj);
40586         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40587         obj_conv.is_owned = false;
40588         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
40589         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40590         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40591         CVec_u8Z_free(ret_var);
40592         return ret_arr;
40593 }
40594
40595 uint64_t  __attribute__((export_name("TS_NodeAlias_read"))) TS_NodeAlias_read(int8_tArray ser) {
40596         LDKu8slice ser_ref;
40597         ser_ref.datalen = ser->arr_len;
40598         ser_ref.data = ser->elems;
40599         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
40600         *ret_conv = NodeAlias_read(ser_ref);
40601         FREE(ser);
40602         return tag_ptr(ret_conv, true);
40603 }
40604
40605 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint64_t this_obj) {
40606         LDKNodeInfo this_obj_conv;
40607         this_obj_conv.inner = untag_ptr(this_obj);
40608         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40610         NodeInfo_free(this_obj_conv);
40611 }
40612
40613 int64_tArray  __attribute__((export_name("TS_NodeInfo_get_channels"))) TS_NodeInfo_get_channels(uint64_t this_ptr) {
40614         LDKNodeInfo this_ptr_conv;
40615         this_ptr_conv.inner = untag_ptr(this_ptr);
40616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40618         this_ptr_conv.is_owned = false;
40619         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
40620         int64_tArray ret_arr = NULL;
40621         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
40622         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
40623         for (size_t i = 0; i < ret_var.datalen; i++) {
40624                 int64_t ret_conv_8_conv = ret_var.data[i];
40625                 ret_arr_ptr[i] = ret_conv_8_conv;
40626         }
40627         
40628         FREE(ret_var.data);
40629         return ret_arr;
40630 }
40631
40632 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint64_t this_ptr, int64_tArray val) {
40633         LDKNodeInfo this_ptr_conv;
40634         this_ptr_conv.inner = untag_ptr(this_ptr);
40635         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40637         this_ptr_conv.is_owned = false;
40638         LDKCVec_u64Z val_constr;
40639         val_constr.datalen = val->arr_len;
40640         if (val_constr.datalen > 0)
40641                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
40642         else
40643                 val_constr.data = NULL;
40644         int64_t* val_vals = val->elems;
40645         for (size_t i = 0; i < val_constr.datalen; i++) {
40646                 int64_t val_conv_8 = val_vals[i];
40647                 val_constr.data[i] = val_conv_8;
40648         }
40649         FREE(val);
40650         NodeInfo_set_channels(&this_ptr_conv, val_constr);
40651 }
40652
40653 uint64_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint64_t this_ptr) {
40654         LDKNodeInfo this_ptr_conv;
40655         this_ptr_conv.inner = untag_ptr(this_ptr);
40656         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40658         this_ptr_conv.is_owned = false;
40659         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
40660         uint64_t ret_ref = 0;
40661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40662         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40663         return ret_ref;
40664 }
40665
40666 void  __attribute__((export_name("TS_NodeInfo_set_lowest_inbound_channel_fees"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint64_t this_ptr, uint64_t val) {
40667         LDKNodeInfo this_ptr_conv;
40668         this_ptr_conv.inner = untag_ptr(this_ptr);
40669         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40671         this_ptr_conv.is_owned = false;
40672         LDKRoutingFees val_conv;
40673         val_conv.inner = untag_ptr(val);
40674         val_conv.is_owned = ptr_is_owned(val);
40675         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40676         val_conv = RoutingFees_clone(&val_conv);
40677         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
40678 }
40679
40680 uint64_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint64_t this_ptr) {
40681         LDKNodeInfo this_ptr_conv;
40682         this_ptr_conv.inner = untag_ptr(this_ptr);
40683         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40685         this_ptr_conv.is_owned = false;
40686         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
40687         uint64_t ret_ref = 0;
40688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40690         return ret_ref;
40691 }
40692
40693 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint64_t this_ptr, uint64_t val) {
40694         LDKNodeInfo this_ptr_conv;
40695         this_ptr_conv.inner = untag_ptr(this_ptr);
40696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40698         this_ptr_conv.is_owned = false;
40699         LDKNodeAnnouncementInfo val_conv;
40700         val_conv.inner = untag_ptr(val);
40701         val_conv.is_owned = ptr_is_owned(val);
40702         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40703         val_conv = NodeAnnouncementInfo_clone(&val_conv);
40704         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
40705 }
40706
40707 uint64_t  __attribute__((export_name("TS_NodeInfo_new"))) TS_NodeInfo_new(int64_tArray channels_arg, uint64_t lowest_inbound_channel_fees_arg, uint64_t announcement_info_arg) {
40708         LDKCVec_u64Z channels_arg_constr;
40709         channels_arg_constr.datalen = channels_arg->arr_len;
40710         if (channels_arg_constr.datalen > 0)
40711                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
40712         else
40713                 channels_arg_constr.data = NULL;
40714         int64_t* channels_arg_vals = channels_arg->elems;
40715         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
40716                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
40717                 channels_arg_constr.data[i] = channels_arg_conv_8;
40718         }
40719         FREE(channels_arg);
40720         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
40721         lowest_inbound_channel_fees_arg_conv.inner = untag_ptr(lowest_inbound_channel_fees_arg);
40722         lowest_inbound_channel_fees_arg_conv.is_owned = ptr_is_owned(lowest_inbound_channel_fees_arg);
40723         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
40724         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
40725         LDKNodeAnnouncementInfo announcement_info_arg_conv;
40726         announcement_info_arg_conv.inner = untag_ptr(announcement_info_arg);
40727         announcement_info_arg_conv.is_owned = ptr_is_owned(announcement_info_arg);
40728         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
40729         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
40730         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
40731         uint64_t ret_ref = 0;
40732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40733         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40734         return ret_ref;
40735 }
40736
40737 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
40738         LDKNodeInfo ret_var = NodeInfo_clone(arg);
40739         uint64_t ret_ref = 0;
40740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40741         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40742         return ret_ref;
40743 }
40744 int64_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint64_t arg) {
40745         LDKNodeInfo arg_conv;
40746         arg_conv.inner = untag_ptr(arg);
40747         arg_conv.is_owned = ptr_is_owned(arg);
40748         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40749         arg_conv.is_owned = false;
40750         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
40751         return ret_conv;
40752 }
40753
40754 uint64_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint64_t orig) {
40755         LDKNodeInfo orig_conv;
40756         orig_conv.inner = untag_ptr(orig);
40757         orig_conv.is_owned = ptr_is_owned(orig);
40758         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40759         orig_conv.is_owned = false;
40760         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
40761         uint64_t ret_ref = 0;
40762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40763         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40764         return ret_ref;
40765 }
40766
40767 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint64_t obj) {
40768         LDKNodeInfo obj_conv;
40769         obj_conv.inner = untag_ptr(obj);
40770         obj_conv.is_owned = ptr_is_owned(obj);
40771         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40772         obj_conv.is_owned = false;
40773         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
40774         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40775         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40776         CVec_u8Z_free(ret_var);
40777         return ret_arr;
40778 }
40779
40780 uint64_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
40781         LDKu8slice ser_ref;
40782         ser_ref.datalen = ser->arr_len;
40783         ser_ref.data = ser->elems;
40784         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
40785         *ret_conv = NodeInfo_read(ser_ref);
40786         FREE(ser);
40787         return tag_ptr(ret_conv, true);
40788 }
40789
40790 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint64_t obj) {
40791         LDKNetworkGraph obj_conv;
40792         obj_conv.inner = untag_ptr(obj);
40793         obj_conv.is_owned = ptr_is_owned(obj);
40794         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40795         obj_conv.is_owned = false;
40796         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
40797         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40798         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40799         CVec_u8Z_free(ret_var);
40800         return ret_arr;
40801 }
40802
40803 uint64_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser, uint64_t arg) {
40804         LDKu8slice ser_ref;
40805         ser_ref.datalen = ser->arr_len;
40806         ser_ref.data = ser->elems;
40807         void* arg_ptr = untag_ptr(arg);
40808         CHECK_ACCESS(arg_ptr);
40809         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
40810         if (arg_conv.free == LDKLogger_JCalls_free) {
40811                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40812                 LDKLogger_JCalls_cloned(&arg_conv);
40813         }
40814         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
40815         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
40816         FREE(ser);
40817         return tag_ptr(ret_conv, true);
40818 }
40819
40820 uint64_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash, uint64_t logger) {
40821         LDKThirtyTwoBytes genesis_hash_ref;
40822         CHECK(genesis_hash->arr_len == 32);
40823         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
40824         void* logger_ptr = untag_ptr(logger);
40825         CHECK_ACCESS(logger_ptr);
40826         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40827         if (logger_conv.free == LDKLogger_JCalls_free) {
40828                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40829                 LDKLogger_JCalls_cloned(&logger_conv);
40830         }
40831         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
40832         uint64_t ret_ref = 0;
40833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40834         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40835         return ret_ref;
40836 }
40837
40838 uint64_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint64_t this_arg) {
40839         LDKNetworkGraph this_arg_conv;
40840         this_arg_conv.inner = untag_ptr(this_arg);
40841         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40843         this_arg_conv.is_owned = false;
40844         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
40845         uint64_t ret_ref = 0;
40846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40847         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40848         return ret_ref;
40849 }
40850
40851 uint64_t  __attribute__((export_name("TS_NetworkGraph_get_last_rapid_gossip_sync_timestamp"))) TS_NetworkGraph_get_last_rapid_gossip_sync_timestamp(uint64_t this_arg) {
40852         LDKNetworkGraph this_arg_conv;
40853         this_arg_conv.inner = untag_ptr(this_arg);
40854         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40856         this_arg_conv.is_owned = false;
40857         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
40858         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
40859         uint64_t ret_ref = tag_ptr(ret_copy, true);
40860         return ret_ref;
40861 }
40862
40863 void  __attribute__((export_name("TS_NetworkGraph_set_last_rapid_gossip_sync_timestamp"))) TS_NetworkGraph_set_last_rapid_gossip_sync_timestamp(uint64_t this_arg, int32_t last_rapid_gossip_sync_timestamp) {
40864         LDKNetworkGraph this_arg_conv;
40865         this_arg_conv.inner = untag_ptr(this_arg);
40866         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40868         this_arg_conv.is_owned = false;
40869         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
40870 }
40871
40872 uint64_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint64_t this_arg, uint64_t msg) {
40873         LDKNetworkGraph this_arg_conv;
40874         this_arg_conv.inner = untag_ptr(this_arg);
40875         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40877         this_arg_conv.is_owned = false;
40878         LDKNodeAnnouncement msg_conv;
40879         msg_conv.inner = untag_ptr(msg);
40880         msg_conv.is_owned = ptr_is_owned(msg);
40881         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40882         msg_conv.is_owned = false;
40883         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40884         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
40885         return tag_ptr(ret_conv, true);
40886 }
40887
40888 uint64_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_unsigned_announcement"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint64_t this_arg, uint64_t msg) {
40889         LDKNetworkGraph this_arg_conv;
40890         this_arg_conv.inner = untag_ptr(this_arg);
40891         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40893         this_arg_conv.is_owned = false;
40894         LDKUnsignedNodeAnnouncement msg_conv;
40895         msg_conv.inner = untag_ptr(msg);
40896         msg_conv.is_owned = ptr_is_owned(msg);
40897         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40898         msg_conv.is_owned = false;
40899         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40900         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
40901         return tag_ptr(ret_conv, true);
40902 }
40903
40904 uint64_t  __attribute__((export_name("TS_NetworkGraph_update_channel_from_announcement"))) TS_NetworkGraph_update_channel_from_announcement(uint64_t this_arg, uint64_t msg, uint64_t chain_access) {
40905         LDKNetworkGraph this_arg_conv;
40906         this_arg_conv.inner = untag_ptr(this_arg);
40907         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40909         this_arg_conv.is_owned = false;
40910         LDKChannelAnnouncement msg_conv;
40911         msg_conv.inner = untag_ptr(msg);
40912         msg_conv.is_owned = ptr_is_owned(msg);
40913         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40914         msg_conv.is_owned = false;
40915         void* chain_access_ptr = untag_ptr(chain_access);
40916         CHECK_ACCESS(chain_access_ptr);
40917         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
40918         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
40919         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
40920                 // Manually implement clone for Java trait instances
40921                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
40922                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40923                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
40924                 }
40925         }
40926         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40927         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
40928         return tag_ptr(ret_conv, true);
40929 }
40930
40931 uint64_t  __attribute__((export_name("TS_NetworkGraph_update_channel_from_unsigned_announcement"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint64_t this_arg, uint64_t msg, uint64_t chain_access) {
40932         LDKNetworkGraph this_arg_conv;
40933         this_arg_conv.inner = untag_ptr(this_arg);
40934         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40936         this_arg_conv.is_owned = false;
40937         LDKUnsignedChannelAnnouncement msg_conv;
40938         msg_conv.inner = untag_ptr(msg);
40939         msg_conv.is_owned = ptr_is_owned(msg);
40940         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40941         msg_conv.is_owned = false;
40942         void* chain_access_ptr = untag_ptr(chain_access);
40943         CHECK_ACCESS(chain_access_ptr);
40944         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
40945         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
40946         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
40947                 // Manually implement clone for Java trait instances
40948                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
40949                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40950                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
40951                 }
40952         }
40953         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40954         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
40955         return tag_ptr(ret_conv, true);
40956 }
40957
40958 uint64_t  __attribute__((export_name("TS_NetworkGraph_add_channel_from_partial_announcement"))) TS_NetworkGraph_add_channel_from_partial_announcement(uint64_t this_arg, int64_t short_channel_id, int64_t timestamp, uint64_t features, int8_tArray node_id_1, int8_tArray node_id_2) {
40959         LDKNetworkGraph this_arg_conv;
40960         this_arg_conv.inner = untag_ptr(this_arg);
40961         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40963         this_arg_conv.is_owned = false;
40964         LDKChannelFeatures features_conv;
40965         features_conv.inner = untag_ptr(features);
40966         features_conv.is_owned = ptr_is_owned(features);
40967         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
40968         features_conv = ChannelFeatures_clone(&features_conv);
40969         LDKPublicKey node_id_1_ref;
40970         CHECK(node_id_1->arr_len == 33);
40971         memcpy(node_id_1_ref.compressed_form, node_id_1->elems, 33); FREE(node_id_1);
40972         LDKPublicKey node_id_2_ref;
40973         CHECK(node_id_2->arr_len == 33);
40974         memcpy(node_id_2_ref.compressed_form, node_id_2->elems, 33); FREE(node_id_2);
40975         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40976         *ret_conv = NetworkGraph_add_channel_from_partial_announcement(&this_arg_conv, short_channel_id, timestamp, features_conv, node_id_1_ref, node_id_2_ref);
40977         return tag_ptr(ret_conv, true);
40978 }
40979
40980 void  __attribute__((export_name("TS_NetworkGraph_channel_failed"))) TS_NetworkGraph_channel_failed(uint64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
40981         LDKNetworkGraph this_arg_conv;
40982         this_arg_conv.inner = untag_ptr(this_arg);
40983         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40985         this_arg_conv.is_owned = false;
40986         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
40987 }
40988
40989 void  __attribute__((export_name("TS_NetworkGraph_node_failed"))) TS_NetworkGraph_node_failed(uint64_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
40990         LDKNetworkGraph this_arg_conv;
40991         this_arg_conv.inner = untag_ptr(this_arg);
40992         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40994         this_arg_conv.is_owned = false;
40995         LDKPublicKey _node_id_ref;
40996         CHECK(_node_id->arr_len == 33);
40997         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
40998         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
40999 }
41000
41001 void  __attribute__((export_name("TS_NetworkGraph_remove_stale_channels_with_time"))) TS_NetworkGraph_remove_stale_channels_with_time(uint64_t this_arg, int64_t current_time_unix) {
41002         LDKNetworkGraph this_arg_conv;
41003         this_arg_conv.inner = untag_ptr(this_arg);
41004         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41006         this_arg_conv.is_owned = false;
41007         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
41008 }
41009
41010 uint64_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint64_t this_arg, uint64_t msg) {
41011         LDKNetworkGraph this_arg_conv;
41012         this_arg_conv.inner = untag_ptr(this_arg);
41013         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41015         this_arg_conv.is_owned = false;
41016         LDKChannelUpdate msg_conv;
41017         msg_conv.inner = untag_ptr(msg);
41018         msg_conv.is_owned = ptr_is_owned(msg);
41019         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41020         msg_conv.is_owned = false;
41021         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41022         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
41023         return tag_ptr(ret_conv, true);
41024 }
41025
41026 uint64_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint64_t this_arg, uint64_t msg) {
41027         LDKNetworkGraph this_arg_conv;
41028         this_arg_conv.inner = untag_ptr(this_arg);
41029         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41031         this_arg_conv.is_owned = false;
41032         LDKUnsignedChannelUpdate msg_conv;
41033         msg_conv.inner = untag_ptr(msg);
41034         msg_conv.is_owned = ptr_is_owned(msg);
41035         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41036         msg_conv.is_owned = false;
41037         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41038         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
41039         return tag_ptr(ret_conv, true);
41040 }
41041
41042 uint64_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_channel"))) TS_ReadOnlyNetworkGraph_channel(uint64_t this_arg, int64_t short_channel_id) {
41043         LDKReadOnlyNetworkGraph this_arg_conv;
41044         this_arg_conv.inner = untag_ptr(this_arg);
41045         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41047         this_arg_conv.is_owned = false;
41048         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
41049         uint64_t ret_ref = 0;
41050         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41051         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41052         return ret_ref;
41053 }
41054
41055 int64_tArray  __attribute__((export_name("TS_ReadOnlyNetworkGraph_list_channels"))) TS_ReadOnlyNetworkGraph_list_channels(uint64_t this_arg) {
41056         LDKReadOnlyNetworkGraph this_arg_conv;
41057         this_arg_conv.inner = untag_ptr(this_arg);
41058         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41060         this_arg_conv.is_owned = false;
41061         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
41062         int64_tArray ret_arr = NULL;
41063         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
41064         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
41065         for (size_t i = 0; i < ret_var.datalen; i++) {
41066                 int64_t ret_conv_8_conv = ret_var.data[i];
41067                 ret_arr_ptr[i] = ret_conv_8_conv;
41068         }
41069         
41070         FREE(ret_var.data);
41071         return ret_arr;
41072 }
41073
41074 uint64_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_node"))) TS_ReadOnlyNetworkGraph_node(uint64_t this_arg, uint64_t node_id) {
41075         LDKReadOnlyNetworkGraph this_arg_conv;
41076         this_arg_conv.inner = untag_ptr(this_arg);
41077         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41079         this_arg_conv.is_owned = false;
41080         LDKNodeId node_id_conv;
41081         node_id_conv.inner = untag_ptr(node_id);
41082         node_id_conv.is_owned = ptr_is_owned(node_id);
41083         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
41084         node_id_conv.is_owned = false;
41085         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
41086         uint64_t ret_ref = 0;
41087         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41088         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41089         return ret_ref;
41090 }
41091
41092 uint64_tArray  __attribute__((export_name("TS_ReadOnlyNetworkGraph_list_nodes"))) TS_ReadOnlyNetworkGraph_list_nodes(uint64_t this_arg) {
41093         LDKReadOnlyNetworkGraph this_arg_conv;
41094         this_arg_conv.inner = untag_ptr(this_arg);
41095         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41097         this_arg_conv.is_owned = false;
41098         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
41099         uint64_tArray ret_arr = NULL;
41100         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
41101         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
41102         for (size_t i = 0; i < ret_var.datalen; i++) {
41103                 LDKNodeId ret_conv_8_var = ret_var.data[i];
41104                 uint64_t ret_conv_8_ref = 0;
41105                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
41106                 ret_conv_8_ref = tag_ptr(ret_conv_8_var.inner, ret_conv_8_var.is_owned);
41107                 ret_arr_ptr[i] = ret_conv_8_ref;
41108         }
41109         
41110         FREE(ret_var.data);
41111         return ret_arr;
41112 }
41113
41114 uint64_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint64_t this_arg, int8_tArray pubkey) {
41115         LDKReadOnlyNetworkGraph this_arg_conv;
41116         this_arg_conv.inner = untag_ptr(this_arg);
41117         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41119         this_arg_conv.is_owned = false;
41120         LDKPublicKey pubkey_ref;
41121         CHECK(pubkey->arr_len == 33);
41122         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
41123         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
41124         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
41125         uint64_t ret_ref = tag_ptr(ret_copy, true);
41126         return ret_ref;
41127 }
41128
41129 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint64_t this_obj) {
41130         LDKRouteHop this_obj_conv;
41131         this_obj_conv.inner = untag_ptr(this_obj);
41132         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41134         RouteHop_free(this_obj_conv);
41135 }
41136
41137 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint64_t this_ptr) {
41138         LDKRouteHop this_ptr_conv;
41139         this_ptr_conv.inner = untag_ptr(this_ptr);
41140         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41142         this_ptr_conv.is_owned = false;
41143         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41144         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
41145         return ret_arr;
41146 }
41147
41148 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint64_t this_ptr, int8_tArray val) {
41149         LDKRouteHop this_ptr_conv;
41150         this_ptr_conv.inner = untag_ptr(this_ptr);
41151         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41153         this_ptr_conv.is_owned = false;
41154         LDKPublicKey val_ref;
41155         CHECK(val->arr_len == 33);
41156         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
41157         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
41158 }
41159
41160 uint64_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint64_t this_ptr) {
41161         LDKRouteHop this_ptr_conv;
41162         this_ptr_conv.inner = untag_ptr(this_ptr);
41163         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41165         this_ptr_conv.is_owned = false;
41166         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
41167         uint64_t ret_ref = 0;
41168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41169         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41170         return ret_ref;
41171 }
41172
41173 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint64_t this_ptr, uint64_t val) {
41174         LDKRouteHop this_ptr_conv;
41175         this_ptr_conv.inner = untag_ptr(this_ptr);
41176         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41178         this_ptr_conv.is_owned = false;
41179         LDKNodeFeatures val_conv;
41180         val_conv.inner = untag_ptr(val);
41181         val_conv.is_owned = ptr_is_owned(val);
41182         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41183         val_conv = NodeFeatures_clone(&val_conv);
41184         RouteHop_set_node_features(&this_ptr_conv, val_conv);
41185 }
41186
41187 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint64_t this_ptr) {
41188         LDKRouteHop this_ptr_conv;
41189         this_ptr_conv.inner = untag_ptr(this_ptr);
41190         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41192         this_ptr_conv.is_owned = false;
41193         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
41194         return ret_conv;
41195 }
41196
41197 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint64_t this_ptr, int64_t val) {
41198         LDKRouteHop this_ptr_conv;
41199         this_ptr_conv.inner = untag_ptr(this_ptr);
41200         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41202         this_ptr_conv.is_owned = false;
41203         RouteHop_set_short_channel_id(&this_ptr_conv, val);
41204 }
41205
41206 uint64_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint64_t this_ptr) {
41207         LDKRouteHop this_ptr_conv;
41208         this_ptr_conv.inner = untag_ptr(this_ptr);
41209         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41211         this_ptr_conv.is_owned = false;
41212         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
41213         uint64_t ret_ref = 0;
41214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41215         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41216         return ret_ref;
41217 }
41218
41219 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint64_t this_ptr, uint64_t val) {
41220         LDKRouteHop this_ptr_conv;
41221         this_ptr_conv.inner = untag_ptr(this_ptr);
41222         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41224         this_ptr_conv.is_owned = false;
41225         LDKChannelFeatures val_conv;
41226         val_conv.inner = untag_ptr(val);
41227         val_conv.is_owned = ptr_is_owned(val);
41228         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41229         val_conv = ChannelFeatures_clone(&val_conv);
41230         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
41231 }
41232
41233 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint64_t this_ptr) {
41234         LDKRouteHop this_ptr_conv;
41235         this_ptr_conv.inner = untag_ptr(this_ptr);
41236         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41238         this_ptr_conv.is_owned = false;
41239         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
41240         return ret_conv;
41241 }
41242
41243 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint64_t this_ptr, int64_t val) {
41244         LDKRouteHop this_ptr_conv;
41245         this_ptr_conv.inner = untag_ptr(this_ptr);
41246         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41248         this_ptr_conv.is_owned = false;
41249         RouteHop_set_fee_msat(&this_ptr_conv, val);
41250 }
41251
41252 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint64_t this_ptr) {
41253         LDKRouteHop this_ptr_conv;
41254         this_ptr_conv.inner = untag_ptr(this_ptr);
41255         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41257         this_ptr_conv.is_owned = false;
41258         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
41259         return ret_conv;
41260 }
41261
41262 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint64_t this_ptr, int32_t val) {
41263         LDKRouteHop this_ptr_conv;
41264         this_ptr_conv.inner = untag_ptr(this_ptr);
41265         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41267         this_ptr_conv.is_owned = false;
41268         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
41269 }
41270
41271 uint64_t  __attribute__((export_name("TS_RouteHop_new"))) TS_RouteHop_new(int8_tArray pubkey_arg, uint64_t node_features_arg, int64_t short_channel_id_arg, uint64_t channel_features_arg, int64_t fee_msat_arg, int32_t cltv_expiry_delta_arg) {
41272         LDKPublicKey pubkey_arg_ref;
41273         CHECK(pubkey_arg->arr_len == 33);
41274         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
41275         LDKNodeFeatures node_features_arg_conv;
41276         node_features_arg_conv.inner = untag_ptr(node_features_arg);
41277         node_features_arg_conv.is_owned = ptr_is_owned(node_features_arg);
41278         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
41279         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
41280         LDKChannelFeatures channel_features_arg_conv;
41281         channel_features_arg_conv.inner = untag_ptr(channel_features_arg);
41282         channel_features_arg_conv.is_owned = ptr_is_owned(channel_features_arg);
41283         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
41284         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
41285         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);
41286         uint64_t ret_ref = 0;
41287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41288         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41289         return ret_ref;
41290 }
41291
41292 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
41293         LDKRouteHop ret_var = RouteHop_clone(arg);
41294         uint64_t ret_ref = 0;
41295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41296         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41297         return ret_ref;
41298 }
41299 int64_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint64_t arg) {
41300         LDKRouteHop arg_conv;
41301         arg_conv.inner = untag_ptr(arg);
41302         arg_conv.is_owned = ptr_is_owned(arg);
41303         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41304         arg_conv.is_owned = false;
41305         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
41306         return ret_conv;
41307 }
41308
41309 uint64_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint64_t orig) {
41310         LDKRouteHop orig_conv;
41311         orig_conv.inner = untag_ptr(orig);
41312         orig_conv.is_owned = ptr_is_owned(orig);
41313         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41314         orig_conv.is_owned = false;
41315         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
41316         uint64_t ret_ref = 0;
41317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41318         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41319         return ret_ref;
41320 }
41321
41322 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint64_t o) {
41323         LDKRouteHop o_conv;
41324         o_conv.inner = untag_ptr(o);
41325         o_conv.is_owned = ptr_is_owned(o);
41326         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41327         o_conv.is_owned = false;
41328         int64_t ret_conv = RouteHop_hash(&o_conv);
41329         return ret_conv;
41330 }
41331
41332 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint64_t a, uint64_t b) {
41333         LDKRouteHop a_conv;
41334         a_conv.inner = untag_ptr(a);
41335         a_conv.is_owned = ptr_is_owned(a);
41336         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41337         a_conv.is_owned = false;
41338         LDKRouteHop b_conv;
41339         b_conv.inner = untag_ptr(b);
41340         b_conv.is_owned = ptr_is_owned(b);
41341         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41342         b_conv.is_owned = false;
41343         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
41344         return ret_conv;
41345 }
41346
41347 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint64_t obj) {
41348         LDKRouteHop obj_conv;
41349         obj_conv.inner = untag_ptr(obj);
41350         obj_conv.is_owned = ptr_is_owned(obj);
41351         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41352         obj_conv.is_owned = false;
41353         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
41354         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41355         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41356         CVec_u8Z_free(ret_var);
41357         return ret_arr;
41358 }
41359
41360 uint64_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
41361         LDKu8slice ser_ref;
41362         ser_ref.datalen = ser->arr_len;
41363         ser_ref.data = ser->elems;
41364         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
41365         *ret_conv = RouteHop_read(ser_ref);
41366         FREE(ser);
41367         return tag_ptr(ret_conv, true);
41368 }
41369
41370 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint64_t this_obj) {
41371         LDKRoute this_obj_conv;
41372         this_obj_conv.inner = untag_ptr(this_obj);
41373         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41375         Route_free(this_obj_conv);
41376 }
41377
41378 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint64_t this_ptr) {
41379         LDKRoute this_ptr_conv;
41380         this_ptr_conv.inner = untag_ptr(this_ptr);
41381         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41383         this_ptr_conv.is_owned = false;
41384         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
41385         ptrArray ret_arr = NULL;
41386         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
41387         uint64_tArray *ret_arr_ptr = (uint64_tArray*)(((uint8_t*)ret_arr) + 8);
41388         for (size_t m = 0; m < ret_var.datalen; m++) {
41389                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
41390                 uint64_tArray ret_conv_12_arr = NULL;
41391                 ret_conv_12_arr = init_uint64_tArray(ret_conv_12_var.datalen, __LINE__);
41392                 uint64_t *ret_conv_12_arr_ptr = (uint64_t*)(((uint8_t*)ret_conv_12_arr) + 8);
41393                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
41394                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
41395                         uint64_t ret_conv_12_conv_10_ref = 0;
41396                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
41397                         ret_conv_12_conv_10_ref = tag_ptr(ret_conv_12_conv_10_var.inner, ret_conv_12_conv_10_var.is_owned);
41398                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
41399                 }
41400                 
41401                 FREE(ret_conv_12_var.data);
41402                 ret_arr_ptr[m] = ret_conv_12_arr;
41403         }
41404         
41405         FREE(ret_var.data);
41406         return ret_arr;
41407 }
41408
41409 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint64_t this_ptr, ptrArray val) {
41410         LDKRoute this_ptr_conv;
41411         this_ptr_conv.inner = untag_ptr(this_ptr);
41412         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41414         this_ptr_conv.is_owned = false;
41415         LDKCVec_CVec_RouteHopZZ val_constr;
41416         val_constr.datalen = val->arr_len;
41417         if (val_constr.datalen > 0)
41418                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41419         else
41420                 val_constr.data = NULL;
41421         uint64_tArray* val_vals = (void*) val->elems;
41422         for (size_t m = 0; m < val_constr.datalen; m++) {
41423                 uint64_tArray val_conv_12 = val_vals[m];
41424                 LDKCVec_RouteHopZ val_conv_12_constr;
41425                 val_conv_12_constr.datalen = val_conv_12->arr_len;
41426                 if (val_conv_12_constr.datalen > 0)
41427                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41428                 else
41429                         val_conv_12_constr.data = NULL;
41430                 uint64_t* val_conv_12_vals = val_conv_12->elems;
41431                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
41432                         uint64_t val_conv_12_conv_10 = val_conv_12_vals[k];
41433                         LDKRouteHop val_conv_12_conv_10_conv;
41434                         val_conv_12_conv_10_conv.inner = untag_ptr(val_conv_12_conv_10);
41435                         val_conv_12_conv_10_conv.is_owned = ptr_is_owned(val_conv_12_conv_10);
41436                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
41437                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
41438                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
41439                 }
41440                 FREE(val_conv_12);
41441                 val_constr.data[m] = val_conv_12_constr;
41442         }
41443         FREE(val);
41444         Route_set_paths(&this_ptr_conv, val_constr);
41445 }
41446
41447 uint64_t  __attribute__((export_name("TS_Route_get_payment_params"))) TS_Route_get_payment_params(uint64_t this_ptr) {
41448         LDKRoute this_ptr_conv;
41449         this_ptr_conv.inner = untag_ptr(this_ptr);
41450         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41452         this_ptr_conv.is_owned = false;
41453         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
41454         uint64_t ret_ref = 0;
41455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41456         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41457         return ret_ref;
41458 }
41459
41460 void  __attribute__((export_name("TS_Route_set_payment_params"))) TS_Route_set_payment_params(uint64_t this_ptr, uint64_t val) {
41461         LDKRoute this_ptr_conv;
41462         this_ptr_conv.inner = untag_ptr(this_ptr);
41463         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41465         this_ptr_conv.is_owned = false;
41466         LDKPaymentParameters val_conv;
41467         val_conv.inner = untag_ptr(val);
41468         val_conv.is_owned = ptr_is_owned(val);
41469         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41470         val_conv = PaymentParameters_clone(&val_conv);
41471         Route_set_payment_params(&this_ptr_conv, val_conv);
41472 }
41473
41474 uint64_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint64_t payment_params_arg) {
41475         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
41476         paths_arg_constr.datalen = paths_arg->arr_len;
41477         if (paths_arg_constr.datalen > 0)
41478                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41479         else
41480                 paths_arg_constr.data = NULL;
41481         uint64_tArray* paths_arg_vals = (void*) paths_arg->elems;
41482         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
41483                 uint64_tArray paths_arg_conv_12 = paths_arg_vals[m];
41484                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
41485                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
41486                 if (paths_arg_conv_12_constr.datalen > 0)
41487                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41488                 else
41489                         paths_arg_conv_12_constr.data = NULL;
41490                 uint64_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems;
41491                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
41492                         uint64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
41493                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
41494                         paths_arg_conv_12_conv_10_conv.inner = untag_ptr(paths_arg_conv_12_conv_10);
41495                         paths_arg_conv_12_conv_10_conv.is_owned = ptr_is_owned(paths_arg_conv_12_conv_10);
41496                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
41497                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
41498                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
41499                 }
41500                 FREE(paths_arg_conv_12);
41501                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
41502         }
41503         FREE(paths_arg);
41504         LDKPaymentParameters payment_params_arg_conv;
41505         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
41506         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
41507         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41508         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41509         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
41510         uint64_t ret_ref = 0;
41511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41512         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41513         return ret_ref;
41514 }
41515
41516 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
41517         LDKRoute ret_var = Route_clone(arg);
41518         uint64_t ret_ref = 0;
41519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41520         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41521         return ret_ref;
41522 }
41523 int64_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint64_t arg) {
41524         LDKRoute arg_conv;
41525         arg_conv.inner = untag_ptr(arg);
41526         arg_conv.is_owned = ptr_is_owned(arg);
41527         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41528         arg_conv.is_owned = false;
41529         int64_t ret_conv = Route_clone_ptr(&arg_conv);
41530         return ret_conv;
41531 }
41532
41533 uint64_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint64_t orig) {
41534         LDKRoute orig_conv;
41535         orig_conv.inner = untag_ptr(orig);
41536         orig_conv.is_owned = ptr_is_owned(orig);
41537         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41538         orig_conv.is_owned = false;
41539         LDKRoute ret_var = Route_clone(&orig_conv);
41540         uint64_t ret_ref = 0;
41541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41542         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41543         return ret_ref;
41544 }
41545
41546 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint64_t o) {
41547         LDKRoute o_conv;
41548         o_conv.inner = untag_ptr(o);
41549         o_conv.is_owned = ptr_is_owned(o);
41550         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41551         o_conv.is_owned = false;
41552         int64_t ret_conv = Route_hash(&o_conv);
41553         return ret_conv;
41554 }
41555
41556 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint64_t a, uint64_t b) {
41557         LDKRoute a_conv;
41558         a_conv.inner = untag_ptr(a);
41559         a_conv.is_owned = ptr_is_owned(a);
41560         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41561         a_conv.is_owned = false;
41562         LDKRoute b_conv;
41563         b_conv.inner = untag_ptr(b);
41564         b_conv.is_owned = ptr_is_owned(b);
41565         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41566         b_conv.is_owned = false;
41567         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
41568         return ret_conv;
41569 }
41570
41571 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint64_t this_arg) {
41572         LDKRoute this_arg_conv;
41573         this_arg_conv.inner = untag_ptr(this_arg);
41574         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41576         this_arg_conv.is_owned = false;
41577         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
41578         return ret_conv;
41579 }
41580
41581 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint64_t this_arg) {
41582         LDKRoute this_arg_conv;
41583         this_arg_conv.inner = untag_ptr(this_arg);
41584         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41586         this_arg_conv.is_owned = false;
41587         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
41588         return ret_conv;
41589 }
41590
41591 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint64_t obj) {
41592         LDKRoute obj_conv;
41593         obj_conv.inner = untag_ptr(obj);
41594         obj_conv.is_owned = ptr_is_owned(obj);
41595         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41596         obj_conv.is_owned = false;
41597         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
41598         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41599         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41600         CVec_u8Z_free(ret_var);
41601         return ret_arr;
41602 }
41603
41604 uint64_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
41605         LDKu8slice ser_ref;
41606         ser_ref.datalen = ser->arr_len;
41607         ser_ref.data = ser->elems;
41608         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
41609         *ret_conv = Route_read(ser_ref);
41610         FREE(ser);
41611         return tag_ptr(ret_conv, true);
41612 }
41613
41614 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint64_t this_obj) {
41615         LDKRouteParameters this_obj_conv;
41616         this_obj_conv.inner = untag_ptr(this_obj);
41617         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41619         RouteParameters_free(this_obj_conv);
41620 }
41621
41622 uint64_t  __attribute__((export_name("TS_RouteParameters_get_payment_params"))) TS_RouteParameters_get_payment_params(uint64_t this_ptr) {
41623         LDKRouteParameters this_ptr_conv;
41624         this_ptr_conv.inner = untag_ptr(this_ptr);
41625         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41627         this_ptr_conv.is_owned = false;
41628         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
41629         uint64_t ret_ref = 0;
41630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41631         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41632         return ret_ref;
41633 }
41634
41635 void  __attribute__((export_name("TS_RouteParameters_set_payment_params"))) TS_RouteParameters_set_payment_params(uint64_t this_ptr, uint64_t val) {
41636         LDKRouteParameters this_ptr_conv;
41637         this_ptr_conv.inner = untag_ptr(this_ptr);
41638         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41640         this_ptr_conv.is_owned = false;
41641         LDKPaymentParameters val_conv;
41642         val_conv.inner = untag_ptr(val);
41643         val_conv.is_owned = ptr_is_owned(val);
41644         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41645         val_conv = PaymentParameters_clone(&val_conv);
41646         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
41647 }
41648
41649 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint64_t this_ptr) {
41650         LDKRouteParameters this_ptr_conv;
41651         this_ptr_conv.inner = untag_ptr(this_ptr);
41652         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41654         this_ptr_conv.is_owned = false;
41655         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
41656         return ret_conv;
41657 }
41658
41659 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint64_t this_ptr, int64_t val) {
41660         LDKRouteParameters this_ptr_conv;
41661         this_ptr_conv.inner = untag_ptr(this_ptr);
41662         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41664         this_ptr_conv.is_owned = false;
41665         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
41666 }
41667
41668 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint64_t this_ptr) {
41669         LDKRouteParameters this_ptr_conv;
41670         this_ptr_conv.inner = untag_ptr(this_ptr);
41671         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41673         this_ptr_conv.is_owned = false;
41674         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
41675         return ret_conv;
41676 }
41677
41678 void  __attribute__((export_name("TS_RouteParameters_set_final_cltv_expiry_delta"))) TS_RouteParameters_set_final_cltv_expiry_delta(uint64_t this_ptr, int32_t val) {
41679         LDKRouteParameters this_ptr_conv;
41680         this_ptr_conv.inner = untag_ptr(this_ptr);
41681         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41683         this_ptr_conv.is_owned = false;
41684         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
41685 }
41686
41687 uint64_t  __attribute__((export_name("TS_RouteParameters_new"))) TS_RouteParameters_new(uint64_t payment_params_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
41688         LDKPaymentParameters payment_params_arg_conv;
41689         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
41690         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
41691         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41692         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41693         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
41694         uint64_t ret_ref = 0;
41695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41696         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41697         return ret_ref;
41698 }
41699
41700 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
41701         LDKRouteParameters ret_var = RouteParameters_clone(arg);
41702         uint64_t ret_ref = 0;
41703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41704         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41705         return ret_ref;
41706 }
41707 int64_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint64_t arg) {
41708         LDKRouteParameters arg_conv;
41709         arg_conv.inner = untag_ptr(arg);
41710         arg_conv.is_owned = ptr_is_owned(arg);
41711         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41712         arg_conv.is_owned = false;
41713         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
41714         return ret_conv;
41715 }
41716
41717 uint64_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint64_t orig) {
41718         LDKRouteParameters orig_conv;
41719         orig_conv.inner = untag_ptr(orig);
41720         orig_conv.is_owned = ptr_is_owned(orig);
41721         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41722         orig_conv.is_owned = false;
41723         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
41724         uint64_t ret_ref = 0;
41725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41726         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41727         return ret_ref;
41728 }
41729
41730 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint64_t obj) {
41731         LDKRouteParameters obj_conv;
41732         obj_conv.inner = untag_ptr(obj);
41733         obj_conv.is_owned = ptr_is_owned(obj);
41734         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41735         obj_conv.is_owned = false;
41736         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
41737         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41738         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41739         CVec_u8Z_free(ret_var);
41740         return ret_arr;
41741 }
41742
41743 uint64_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
41744         LDKu8slice ser_ref;
41745         ser_ref.datalen = ser->arr_len;
41746         ser_ref.data = ser->elems;
41747         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
41748         *ret_conv = RouteParameters_read(ser_ref);
41749         FREE(ser);
41750         return tag_ptr(ret_conv, true);
41751 }
41752
41753 void  __attribute__((export_name("TS_PaymentParameters_free"))) TS_PaymentParameters_free(uint64_t this_obj) {
41754         LDKPaymentParameters this_obj_conv;
41755         this_obj_conv.inner = untag_ptr(this_obj);
41756         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41758         PaymentParameters_free(this_obj_conv);
41759 }
41760
41761 int8_tArray  __attribute__((export_name("TS_PaymentParameters_get_payee_pubkey"))) TS_PaymentParameters_get_payee_pubkey(uint64_t this_ptr) {
41762         LDKPaymentParameters this_ptr_conv;
41763         this_ptr_conv.inner = untag_ptr(this_ptr);
41764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41766         this_ptr_conv.is_owned = false;
41767         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41768         memcpy(ret_arr->elems, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form, 33);
41769         return ret_arr;
41770 }
41771
41772 void  __attribute__((export_name("TS_PaymentParameters_set_payee_pubkey"))) TS_PaymentParameters_set_payee_pubkey(uint64_t this_ptr, int8_tArray val) {
41773         LDKPaymentParameters this_ptr_conv;
41774         this_ptr_conv.inner = untag_ptr(this_ptr);
41775         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41777         this_ptr_conv.is_owned = false;
41778         LDKPublicKey val_ref;
41779         CHECK(val->arr_len == 33);
41780         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
41781         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
41782 }
41783
41784 uint64_t  __attribute__((export_name("TS_PaymentParameters_get_features"))) TS_PaymentParameters_get_features(uint64_t this_ptr) {
41785         LDKPaymentParameters this_ptr_conv;
41786         this_ptr_conv.inner = untag_ptr(this_ptr);
41787         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41789         this_ptr_conv.is_owned = false;
41790         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
41791         uint64_t ret_ref = 0;
41792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41793         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41794         return ret_ref;
41795 }
41796
41797 void  __attribute__((export_name("TS_PaymentParameters_set_features"))) TS_PaymentParameters_set_features(uint64_t this_ptr, uint64_t val) {
41798         LDKPaymentParameters this_ptr_conv;
41799         this_ptr_conv.inner = untag_ptr(this_ptr);
41800         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41802         this_ptr_conv.is_owned = false;
41803         LDKInvoiceFeatures val_conv;
41804         val_conv.inner = untag_ptr(val);
41805         val_conv.is_owned = ptr_is_owned(val);
41806         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41807         val_conv = InvoiceFeatures_clone(&val_conv);
41808         PaymentParameters_set_features(&this_ptr_conv, val_conv);
41809 }
41810
41811 uint64_tArray  __attribute__((export_name("TS_PaymentParameters_get_route_hints"))) TS_PaymentParameters_get_route_hints(uint64_t this_ptr) {
41812         LDKPaymentParameters this_ptr_conv;
41813         this_ptr_conv.inner = untag_ptr(this_ptr);
41814         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41816         this_ptr_conv.is_owned = false;
41817         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
41818         uint64_tArray ret_arr = NULL;
41819         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
41820         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
41821         for (size_t l = 0; l < ret_var.datalen; l++) {
41822                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
41823                 uint64_t ret_conv_11_ref = 0;
41824                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
41825                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
41826                 ret_arr_ptr[l] = ret_conv_11_ref;
41827         }
41828         
41829         FREE(ret_var.data);
41830         return ret_arr;
41831 }
41832
41833 void  __attribute__((export_name("TS_PaymentParameters_set_route_hints"))) TS_PaymentParameters_set_route_hints(uint64_t this_ptr, uint64_tArray val) {
41834         LDKPaymentParameters this_ptr_conv;
41835         this_ptr_conv.inner = untag_ptr(this_ptr);
41836         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41838         this_ptr_conv.is_owned = false;
41839         LDKCVec_RouteHintZ val_constr;
41840         val_constr.datalen = val->arr_len;
41841         if (val_constr.datalen > 0)
41842                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
41843         else
41844                 val_constr.data = NULL;
41845         uint64_t* val_vals = val->elems;
41846         for (size_t l = 0; l < val_constr.datalen; l++) {
41847                 uint64_t val_conv_11 = val_vals[l];
41848                 LDKRouteHint val_conv_11_conv;
41849                 val_conv_11_conv.inner = untag_ptr(val_conv_11);
41850                 val_conv_11_conv.is_owned = ptr_is_owned(val_conv_11);
41851                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
41852                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
41853                 val_constr.data[l] = val_conv_11_conv;
41854         }
41855         FREE(val);
41856         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
41857 }
41858
41859 uint64_t  __attribute__((export_name("TS_PaymentParameters_get_expiry_time"))) TS_PaymentParameters_get_expiry_time(uint64_t this_ptr) {
41860         LDKPaymentParameters this_ptr_conv;
41861         this_ptr_conv.inner = untag_ptr(this_ptr);
41862         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41864         this_ptr_conv.is_owned = false;
41865         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41866         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
41867         uint64_t ret_ref = tag_ptr(ret_copy, true);
41868         return ret_ref;
41869 }
41870
41871 void  __attribute__((export_name("TS_PaymentParameters_set_expiry_time"))) TS_PaymentParameters_set_expiry_time(uint64_t this_ptr, uint64_t val) {
41872         LDKPaymentParameters this_ptr_conv;
41873         this_ptr_conv.inner = untag_ptr(this_ptr);
41874         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41876         this_ptr_conv.is_owned = false;
41877         void* val_ptr = untag_ptr(val);
41878         CHECK_ACCESS(val_ptr);
41879         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41880         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
41881         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
41882 }
41883
41884 int32_t  __attribute__((export_name("TS_PaymentParameters_get_max_total_cltv_expiry_delta"))) TS_PaymentParameters_get_max_total_cltv_expiry_delta(uint64_t this_ptr) {
41885         LDKPaymentParameters this_ptr_conv;
41886         this_ptr_conv.inner = untag_ptr(this_ptr);
41887         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41889         this_ptr_conv.is_owned = false;
41890         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
41891         return ret_conv;
41892 }
41893
41894 void  __attribute__((export_name("TS_PaymentParameters_set_max_total_cltv_expiry_delta"))) TS_PaymentParameters_set_max_total_cltv_expiry_delta(uint64_t this_ptr, int32_t val) {
41895         LDKPaymentParameters this_ptr_conv;
41896         this_ptr_conv.inner = untag_ptr(this_ptr);
41897         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41899         this_ptr_conv.is_owned = false;
41900         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
41901 }
41902
41903 int8_t  __attribute__((export_name("TS_PaymentParameters_get_max_path_count"))) TS_PaymentParameters_get_max_path_count(uint64_t this_ptr) {
41904         LDKPaymentParameters this_ptr_conv;
41905         this_ptr_conv.inner = untag_ptr(this_ptr);
41906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41908         this_ptr_conv.is_owned = false;
41909         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
41910         return ret_conv;
41911 }
41912
41913 void  __attribute__((export_name("TS_PaymentParameters_set_max_path_count"))) TS_PaymentParameters_set_max_path_count(uint64_t this_ptr, int8_t val) {
41914         LDKPaymentParameters this_ptr_conv;
41915         this_ptr_conv.inner = untag_ptr(this_ptr);
41916         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41918         this_ptr_conv.is_owned = false;
41919         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
41920 }
41921
41922 int8_t  __attribute__((export_name("TS_PaymentParameters_get_max_channel_saturation_power_of_half"))) TS_PaymentParameters_get_max_channel_saturation_power_of_half(uint64_t this_ptr) {
41923         LDKPaymentParameters this_ptr_conv;
41924         this_ptr_conv.inner = untag_ptr(this_ptr);
41925         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41927         this_ptr_conv.is_owned = false;
41928         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
41929         return ret_conv;
41930 }
41931
41932 void  __attribute__((export_name("TS_PaymentParameters_set_max_channel_saturation_power_of_half"))) TS_PaymentParameters_set_max_channel_saturation_power_of_half(uint64_t this_ptr, int8_t val) {
41933         LDKPaymentParameters this_ptr_conv;
41934         this_ptr_conv.inner = untag_ptr(this_ptr);
41935         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41937         this_ptr_conv.is_owned = false;
41938         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
41939 }
41940
41941 int64_tArray  __attribute__((export_name("TS_PaymentParameters_get_previously_failed_channels"))) TS_PaymentParameters_get_previously_failed_channels(uint64_t this_ptr) {
41942         LDKPaymentParameters this_ptr_conv;
41943         this_ptr_conv.inner = untag_ptr(this_ptr);
41944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41946         this_ptr_conv.is_owned = false;
41947         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
41948         int64_tArray ret_arr = NULL;
41949         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
41950         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
41951         for (size_t i = 0; i < ret_var.datalen; i++) {
41952                 int64_t ret_conv_8_conv = ret_var.data[i];
41953                 ret_arr_ptr[i] = ret_conv_8_conv;
41954         }
41955         
41956         FREE(ret_var.data);
41957         return ret_arr;
41958 }
41959
41960 void  __attribute__((export_name("TS_PaymentParameters_set_previously_failed_channels"))) TS_PaymentParameters_set_previously_failed_channels(uint64_t this_ptr, int64_tArray val) {
41961         LDKPaymentParameters this_ptr_conv;
41962         this_ptr_conv.inner = untag_ptr(this_ptr);
41963         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41965         this_ptr_conv.is_owned = false;
41966         LDKCVec_u64Z val_constr;
41967         val_constr.datalen = val->arr_len;
41968         if (val_constr.datalen > 0)
41969                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
41970         else
41971                 val_constr.data = NULL;
41972         int64_t* val_vals = val->elems;
41973         for (size_t i = 0; i < val_constr.datalen; i++) {
41974                 int64_t val_conv_8 = val_vals[i];
41975                 val_constr.data[i] = val_conv_8;
41976         }
41977         FREE(val);
41978         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
41979 }
41980
41981 uint64_t  __attribute__((export_name("TS_PaymentParameters_new"))) TS_PaymentParameters_new(int8_tArray payee_pubkey_arg, uint64_t features_arg, uint64_tArray route_hints_arg, uint64_t expiry_time_arg, int32_t max_total_cltv_expiry_delta_arg, int8_t max_path_count_arg, int8_t max_channel_saturation_power_of_half_arg, int64_tArray previously_failed_channels_arg) {
41982         LDKPublicKey payee_pubkey_arg_ref;
41983         CHECK(payee_pubkey_arg->arr_len == 33);
41984         memcpy(payee_pubkey_arg_ref.compressed_form, payee_pubkey_arg->elems, 33); FREE(payee_pubkey_arg);
41985         LDKInvoiceFeatures features_arg_conv;
41986         features_arg_conv.inner = untag_ptr(features_arg);
41987         features_arg_conv.is_owned = ptr_is_owned(features_arg);
41988         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
41989         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
41990         LDKCVec_RouteHintZ route_hints_arg_constr;
41991         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
41992         if (route_hints_arg_constr.datalen > 0)
41993                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
41994         else
41995                 route_hints_arg_constr.data = NULL;
41996         uint64_t* route_hints_arg_vals = route_hints_arg->elems;
41997         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
41998                 uint64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
41999                 LDKRouteHint route_hints_arg_conv_11_conv;
42000                 route_hints_arg_conv_11_conv.inner = untag_ptr(route_hints_arg_conv_11);
42001                 route_hints_arg_conv_11_conv.is_owned = ptr_is_owned(route_hints_arg_conv_11);
42002                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
42003                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
42004                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
42005         }
42006         FREE(route_hints_arg);
42007         void* expiry_time_arg_ptr = untag_ptr(expiry_time_arg);
42008         CHECK_ACCESS(expiry_time_arg_ptr);
42009         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
42010         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(expiry_time_arg));
42011         LDKCVec_u64Z previously_failed_channels_arg_constr;
42012         previously_failed_channels_arg_constr.datalen = previously_failed_channels_arg->arr_len;
42013         if (previously_failed_channels_arg_constr.datalen > 0)
42014                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
42015         else
42016                 previously_failed_channels_arg_constr.data = NULL;
42017         int64_t* previously_failed_channels_arg_vals = previously_failed_channels_arg->elems;
42018         for (size_t i = 0; i < previously_failed_channels_arg_constr.datalen; i++) {
42019                 int64_t previously_failed_channels_arg_conv_8 = previously_failed_channels_arg_vals[i];
42020                 previously_failed_channels_arg_constr.data[i] = previously_failed_channels_arg_conv_8;
42021         }
42022         FREE(previously_failed_channels_arg);
42023         LDKPaymentParameters ret_var = PaymentParameters_new(payee_pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv, max_total_cltv_expiry_delta_arg, max_path_count_arg, max_channel_saturation_power_of_half_arg, previously_failed_channels_arg_constr);
42024         uint64_t ret_ref = 0;
42025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42026         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42027         return ret_ref;
42028 }
42029
42030 static inline uint64_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
42031         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
42032         uint64_t ret_ref = 0;
42033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42034         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42035         return ret_ref;
42036 }
42037 int64_t  __attribute__((export_name("TS_PaymentParameters_clone_ptr"))) TS_PaymentParameters_clone_ptr(uint64_t arg) {
42038         LDKPaymentParameters arg_conv;
42039         arg_conv.inner = untag_ptr(arg);
42040         arg_conv.is_owned = ptr_is_owned(arg);
42041         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42042         arg_conv.is_owned = false;
42043         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
42044         return ret_conv;
42045 }
42046
42047 uint64_t  __attribute__((export_name("TS_PaymentParameters_clone"))) TS_PaymentParameters_clone(uint64_t orig) {
42048         LDKPaymentParameters orig_conv;
42049         orig_conv.inner = untag_ptr(orig);
42050         orig_conv.is_owned = ptr_is_owned(orig);
42051         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42052         orig_conv.is_owned = false;
42053         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
42054         uint64_t ret_ref = 0;
42055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42056         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42057         return ret_ref;
42058 }
42059
42060 int64_t  __attribute__((export_name("TS_PaymentParameters_hash"))) TS_PaymentParameters_hash(uint64_t o) {
42061         LDKPaymentParameters o_conv;
42062         o_conv.inner = untag_ptr(o);
42063         o_conv.is_owned = ptr_is_owned(o);
42064         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42065         o_conv.is_owned = false;
42066         int64_t ret_conv = PaymentParameters_hash(&o_conv);
42067         return ret_conv;
42068 }
42069
42070 jboolean  __attribute__((export_name("TS_PaymentParameters_eq"))) TS_PaymentParameters_eq(uint64_t a, uint64_t b) {
42071         LDKPaymentParameters a_conv;
42072         a_conv.inner = untag_ptr(a);
42073         a_conv.is_owned = ptr_is_owned(a);
42074         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42075         a_conv.is_owned = false;
42076         LDKPaymentParameters b_conv;
42077         b_conv.inner = untag_ptr(b);
42078         b_conv.is_owned = ptr_is_owned(b);
42079         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42080         b_conv.is_owned = false;
42081         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
42082         return ret_conv;
42083 }
42084
42085 int8_tArray  __attribute__((export_name("TS_PaymentParameters_write"))) TS_PaymentParameters_write(uint64_t obj) {
42086         LDKPaymentParameters obj_conv;
42087         obj_conv.inner = untag_ptr(obj);
42088         obj_conv.is_owned = ptr_is_owned(obj);
42089         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42090         obj_conv.is_owned = false;
42091         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
42092         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42093         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42094         CVec_u8Z_free(ret_var);
42095         return ret_arr;
42096 }
42097
42098 uint64_t  __attribute__((export_name("TS_PaymentParameters_read"))) TS_PaymentParameters_read(int8_tArray ser) {
42099         LDKu8slice ser_ref;
42100         ser_ref.datalen = ser->arr_len;
42101         ser_ref.data = ser->elems;
42102         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
42103         *ret_conv = PaymentParameters_read(ser_ref);
42104         FREE(ser);
42105         return tag_ptr(ret_conv, true);
42106 }
42107
42108 uint64_t  __attribute__((export_name("TS_PaymentParameters_from_node_id"))) TS_PaymentParameters_from_node_id(int8_tArray payee_pubkey) {
42109         LDKPublicKey payee_pubkey_ref;
42110         CHECK(payee_pubkey->arr_len == 33);
42111         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
42112         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
42113         uint64_t ret_ref = 0;
42114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42115         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42116         return ret_ref;
42117 }
42118
42119 uint64_t  __attribute__((export_name("TS_PaymentParameters_for_keysend"))) TS_PaymentParameters_for_keysend(int8_tArray payee_pubkey) {
42120         LDKPublicKey payee_pubkey_ref;
42121         CHECK(payee_pubkey->arr_len == 33);
42122         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
42123         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
42124         uint64_t ret_ref = 0;
42125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42126         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42127         return ret_ref;
42128 }
42129
42130 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint64_t this_obj) {
42131         LDKRouteHint this_obj_conv;
42132         this_obj_conv.inner = untag_ptr(this_obj);
42133         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42135         RouteHint_free(this_obj_conv);
42136 }
42137
42138 uint64_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint64_t this_ptr) {
42139         LDKRouteHint this_ptr_conv;
42140         this_ptr_conv.inner = untag_ptr(this_ptr);
42141         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42143         this_ptr_conv.is_owned = false;
42144         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
42145         uint64_tArray ret_arr = NULL;
42146         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
42147         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
42148         for (size_t o = 0; o < ret_var.datalen; o++) {
42149                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
42150                 uint64_t ret_conv_14_ref = 0;
42151                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
42152                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
42153                 ret_arr_ptr[o] = ret_conv_14_ref;
42154         }
42155         
42156         FREE(ret_var.data);
42157         return ret_arr;
42158 }
42159
42160 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint64_t this_ptr, uint64_tArray val) {
42161         LDKRouteHint this_ptr_conv;
42162         this_ptr_conv.inner = untag_ptr(this_ptr);
42163         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42165         this_ptr_conv.is_owned = false;
42166         LDKCVec_RouteHintHopZ val_constr;
42167         val_constr.datalen = val->arr_len;
42168         if (val_constr.datalen > 0)
42169                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
42170         else
42171                 val_constr.data = NULL;
42172         uint64_t* val_vals = val->elems;
42173         for (size_t o = 0; o < val_constr.datalen; o++) {
42174                 uint64_t val_conv_14 = val_vals[o];
42175                 LDKRouteHintHop val_conv_14_conv;
42176                 val_conv_14_conv.inner = untag_ptr(val_conv_14);
42177                 val_conv_14_conv.is_owned = ptr_is_owned(val_conv_14);
42178                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
42179                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
42180                 val_constr.data[o] = val_conv_14_conv;
42181         }
42182         FREE(val);
42183         RouteHint_set_a(&this_ptr_conv, val_constr);
42184 }
42185
42186 uint64_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint64_tArray a_arg) {
42187         LDKCVec_RouteHintHopZ a_arg_constr;
42188         a_arg_constr.datalen = a_arg->arr_len;
42189         if (a_arg_constr.datalen > 0)
42190                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
42191         else
42192                 a_arg_constr.data = NULL;
42193         uint64_t* a_arg_vals = a_arg->elems;
42194         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
42195                 uint64_t a_arg_conv_14 = a_arg_vals[o];
42196                 LDKRouteHintHop a_arg_conv_14_conv;
42197                 a_arg_conv_14_conv.inner = untag_ptr(a_arg_conv_14);
42198                 a_arg_conv_14_conv.is_owned = ptr_is_owned(a_arg_conv_14);
42199                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
42200                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
42201                 a_arg_constr.data[o] = a_arg_conv_14_conv;
42202         }
42203         FREE(a_arg);
42204         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
42205         uint64_t ret_ref = 0;
42206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42207         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42208         return ret_ref;
42209 }
42210
42211 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
42212         LDKRouteHint ret_var = RouteHint_clone(arg);
42213         uint64_t ret_ref = 0;
42214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42215         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42216         return ret_ref;
42217 }
42218 int64_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint64_t arg) {
42219         LDKRouteHint arg_conv;
42220         arg_conv.inner = untag_ptr(arg);
42221         arg_conv.is_owned = ptr_is_owned(arg);
42222         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42223         arg_conv.is_owned = false;
42224         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
42225         return ret_conv;
42226 }
42227
42228 uint64_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint64_t orig) {
42229         LDKRouteHint orig_conv;
42230         orig_conv.inner = untag_ptr(orig);
42231         orig_conv.is_owned = ptr_is_owned(orig);
42232         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42233         orig_conv.is_owned = false;
42234         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
42235         uint64_t ret_ref = 0;
42236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42237         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42238         return ret_ref;
42239 }
42240
42241 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint64_t o) {
42242         LDKRouteHint o_conv;
42243         o_conv.inner = untag_ptr(o);
42244         o_conv.is_owned = ptr_is_owned(o);
42245         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42246         o_conv.is_owned = false;
42247         int64_t ret_conv = RouteHint_hash(&o_conv);
42248         return ret_conv;
42249 }
42250
42251 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint64_t a, uint64_t b) {
42252         LDKRouteHint a_conv;
42253         a_conv.inner = untag_ptr(a);
42254         a_conv.is_owned = ptr_is_owned(a);
42255         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42256         a_conv.is_owned = false;
42257         LDKRouteHint b_conv;
42258         b_conv.inner = untag_ptr(b);
42259         b_conv.is_owned = ptr_is_owned(b);
42260         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42261         b_conv.is_owned = false;
42262         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
42263         return ret_conv;
42264 }
42265
42266 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint64_t obj) {
42267         LDKRouteHint obj_conv;
42268         obj_conv.inner = untag_ptr(obj);
42269         obj_conv.is_owned = ptr_is_owned(obj);
42270         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42271         obj_conv.is_owned = false;
42272         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
42273         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42274         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42275         CVec_u8Z_free(ret_var);
42276         return ret_arr;
42277 }
42278
42279 uint64_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
42280         LDKu8slice ser_ref;
42281         ser_ref.datalen = ser->arr_len;
42282         ser_ref.data = ser->elems;
42283         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
42284         *ret_conv = RouteHint_read(ser_ref);
42285         FREE(ser);
42286         return tag_ptr(ret_conv, true);
42287 }
42288
42289 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint64_t this_obj) {
42290         LDKRouteHintHop this_obj_conv;
42291         this_obj_conv.inner = untag_ptr(this_obj);
42292         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42294         RouteHintHop_free(this_obj_conv);
42295 }
42296
42297 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint64_t this_ptr) {
42298         LDKRouteHintHop this_ptr_conv;
42299         this_ptr_conv.inner = untag_ptr(this_ptr);
42300         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42302         this_ptr_conv.is_owned = false;
42303         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
42304         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
42305         return ret_arr;
42306 }
42307
42308 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint64_t this_ptr, int8_tArray val) {
42309         LDKRouteHintHop this_ptr_conv;
42310         this_ptr_conv.inner = untag_ptr(this_ptr);
42311         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42313         this_ptr_conv.is_owned = false;
42314         LDKPublicKey val_ref;
42315         CHECK(val->arr_len == 33);
42316         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
42317         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
42318 }
42319
42320 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint64_t this_ptr) {
42321         LDKRouteHintHop this_ptr_conv;
42322         this_ptr_conv.inner = untag_ptr(this_ptr);
42323         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42325         this_ptr_conv.is_owned = false;
42326         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
42327         return ret_conv;
42328 }
42329
42330 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint64_t this_ptr, int64_t val) {
42331         LDKRouteHintHop this_ptr_conv;
42332         this_ptr_conv.inner = untag_ptr(this_ptr);
42333         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42335         this_ptr_conv.is_owned = false;
42336         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
42337 }
42338
42339 uint64_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint64_t this_ptr) {
42340         LDKRouteHintHop this_ptr_conv;
42341         this_ptr_conv.inner = untag_ptr(this_ptr);
42342         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42344         this_ptr_conv.is_owned = false;
42345         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
42346         uint64_t ret_ref = 0;
42347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42348         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42349         return ret_ref;
42350 }
42351
42352 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint64_t this_ptr, uint64_t val) {
42353         LDKRouteHintHop this_ptr_conv;
42354         this_ptr_conv.inner = untag_ptr(this_ptr);
42355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42357         this_ptr_conv.is_owned = false;
42358         LDKRoutingFees val_conv;
42359         val_conv.inner = untag_ptr(val);
42360         val_conv.is_owned = ptr_is_owned(val);
42361         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42362         val_conv = RoutingFees_clone(&val_conv);
42363         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
42364 }
42365
42366 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint64_t this_ptr) {
42367         LDKRouteHintHop this_ptr_conv;
42368         this_ptr_conv.inner = untag_ptr(this_ptr);
42369         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42371         this_ptr_conv.is_owned = false;
42372         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
42373         return ret_conv;
42374 }
42375
42376 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint64_t this_ptr, int16_t val) {
42377         LDKRouteHintHop this_ptr_conv;
42378         this_ptr_conv.inner = untag_ptr(this_ptr);
42379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42381         this_ptr_conv.is_owned = false;
42382         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
42383 }
42384
42385 uint64_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint64_t this_ptr) {
42386         LDKRouteHintHop this_ptr_conv;
42387         this_ptr_conv.inner = untag_ptr(this_ptr);
42388         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42390         this_ptr_conv.is_owned = false;
42391         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42392         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
42393         uint64_t ret_ref = tag_ptr(ret_copy, true);
42394         return ret_ref;
42395 }
42396
42397 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint64_t this_ptr, uint64_t val) {
42398         LDKRouteHintHop this_ptr_conv;
42399         this_ptr_conv.inner = untag_ptr(this_ptr);
42400         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42402         this_ptr_conv.is_owned = false;
42403         void* val_ptr = untag_ptr(val);
42404         CHECK_ACCESS(val_ptr);
42405         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42406         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
42407         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
42408 }
42409
42410 uint64_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint64_t this_ptr) {
42411         LDKRouteHintHop this_ptr_conv;
42412         this_ptr_conv.inner = untag_ptr(this_ptr);
42413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42415         this_ptr_conv.is_owned = false;
42416         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42417         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
42418         uint64_t ret_ref = tag_ptr(ret_copy, true);
42419         return ret_ref;
42420 }
42421
42422 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint64_t this_ptr, uint64_t val) {
42423         LDKRouteHintHop this_ptr_conv;
42424         this_ptr_conv.inner = untag_ptr(this_ptr);
42425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42427         this_ptr_conv.is_owned = false;
42428         void* val_ptr = untag_ptr(val);
42429         CHECK_ACCESS(val_ptr);
42430         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42431         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
42432         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
42433 }
42434
42435 uint64_t  __attribute__((export_name("TS_RouteHintHop_new"))) TS_RouteHintHop_new(int8_tArray src_node_id_arg, int64_t short_channel_id_arg, uint64_t fees_arg, int16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg) {
42436         LDKPublicKey src_node_id_arg_ref;
42437         CHECK(src_node_id_arg->arr_len == 33);
42438         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
42439         LDKRoutingFees fees_arg_conv;
42440         fees_arg_conv.inner = untag_ptr(fees_arg);
42441         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
42442         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
42443         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
42444         void* htlc_minimum_msat_arg_ptr = untag_ptr(htlc_minimum_msat_arg);
42445         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
42446         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
42447         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_minimum_msat_arg));
42448         void* htlc_maximum_msat_arg_ptr = untag_ptr(htlc_maximum_msat_arg);
42449         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
42450         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
42451         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat_arg));
42452         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);
42453         uint64_t ret_ref = 0;
42454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42455         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42456         return ret_ref;
42457 }
42458
42459 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
42460         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
42461         uint64_t ret_ref = 0;
42462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42463         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42464         return ret_ref;
42465 }
42466 int64_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint64_t arg) {
42467         LDKRouteHintHop arg_conv;
42468         arg_conv.inner = untag_ptr(arg);
42469         arg_conv.is_owned = ptr_is_owned(arg);
42470         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42471         arg_conv.is_owned = false;
42472         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
42473         return ret_conv;
42474 }
42475
42476 uint64_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint64_t orig) {
42477         LDKRouteHintHop orig_conv;
42478         orig_conv.inner = untag_ptr(orig);
42479         orig_conv.is_owned = ptr_is_owned(orig);
42480         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42481         orig_conv.is_owned = false;
42482         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
42483         uint64_t ret_ref = 0;
42484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42485         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42486         return ret_ref;
42487 }
42488
42489 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint64_t o) {
42490         LDKRouteHintHop o_conv;
42491         o_conv.inner = untag_ptr(o);
42492         o_conv.is_owned = ptr_is_owned(o);
42493         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42494         o_conv.is_owned = false;
42495         int64_t ret_conv = RouteHintHop_hash(&o_conv);
42496         return ret_conv;
42497 }
42498
42499 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint64_t a, uint64_t b) {
42500         LDKRouteHintHop a_conv;
42501         a_conv.inner = untag_ptr(a);
42502         a_conv.is_owned = ptr_is_owned(a);
42503         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42504         a_conv.is_owned = false;
42505         LDKRouteHintHop b_conv;
42506         b_conv.inner = untag_ptr(b);
42507         b_conv.is_owned = ptr_is_owned(b);
42508         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42509         b_conv.is_owned = false;
42510         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
42511         return ret_conv;
42512 }
42513
42514 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint64_t obj) {
42515         LDKRouteHintHop obj_conv;
42516         obj_conv.inner = untag_ptr(obj);
42517         obj_conv.is_owned = ptr_is_owned(obj);
42518         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42519         obj_conv.is_owned = false;
42520         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
42521         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42522         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42523         CVec_u8Z_free(ret_var);
42524         return ret_arr;
42525 }
42526
42527 uint64_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
42528         LDKu8slice ser_ref;
42529         ser_ref.datalen = ser->arr_len;
42530         ser_ref.data = ser->elems;
42531         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
42532         *ret_conv = RouteHintHop_read(ser_ref);
42533         FREE(ser);
42534         return tag_ptr(ret_conv, true);
42535 }
42536
42537 uint64_t  __attribute__((export_name("TS_find_route"))) TS_find_route(int8_tArray our_node_pubkey, uint64_t route_params, uint64_t network_graph, uint64_tArray first_hops, uint64_t logger, uint64_t scorer, int8_tArray random_seed_bytes) {
42538         LDKPublicKey our_node_pubkey_ref;
42539         CHECK(our_node_pubkey->arr_len == 33);
42540         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
42541         LDKRouteParameters route_params_conv;
42542         route_params_conv.inner = untag_ptr(route_params);
42543         route_params_conv.is_owned = ptr_is_owned(route_params);
42544         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
42545         route_params_conv.is_owned = false;
42546         LDKNetworkGraph network_graph_conv;
42547         network_graph_conv.inner = untag_ptr(network_graph);
42548         network_graph_conv.is_owned = ptr_is_owned(network_graph);
42549         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42550         network_graph_conv.is_owned = false;
42551         LDKCVec_ChannelDetailsZ first_hops_constr;
42552         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
42553         if (first_hops != 0) {
42554                 first_hops_constr.datalen = first_hops->arr_len;
42555                 if (first_hops_constr.datalen > 0)
42556                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
42557                 else
42558                         first_hops_constr.data = NULL;
42559                 uint64_t* first_hops_vals = first_hops->elems;
42560                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
42561                         uint64_t first_hops_conv_16 = first_hops_vals[q];
42562                         LDKChannelDetails first_hops_conv_16_conv;
42563                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
42564                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
42565                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
42566                         first_hops_conv_16_conv.is_owned = false;
42567                         first_hops_constr.data[q] = first_hops_conv_16_conv;
42568                 }
42569                 FREE(first_hops);
42570                 first_hops_ptr = &first_hops_constr;
42571         }
42572         void* logger_ptr = untag_ptr(logger);
42573         CHECK_ACCESS(logger_ptr);
42574         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42575         if (logger_conv.free == LDKLogger_JCalls_free) {
42576                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42577                 LDKLogger_JCalls_cloned(&logger_conv);
42578         }
42579         void* scorer_ptr = untag_ptr(scorer);
42580         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
42581         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
42582         unsigned char random_seed_bytes_arr[32];
42583         CHECK(random_seed_bytes->arr_len == 32);
42584         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
42585         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
42586         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
42587         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_graph_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
42588         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
42589         return tag_ptr(ret_conv, true);
42590 }
42591
42592 uint64_t  __attribute__((export_name("TS_build_route_from_hops"))) TS_build_route_from_hops(int8_tArray our_node_pubkey, ptrArray hops, uint64_t route_params, uint64_t network_graph, uint64_t logger, int8_tArray random_seed_bytes) {
42593         LDKPublicKey our_node_pubkey_ref;
42594         CHECK(our_node_pubkey->arr_len == 33);
42595         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
42596         LDKCVec_PublicKeyZ hops_constr;
42597         hops_constr.datalen = hops->arr_len;
42598         if (hops_constr.datalen > 0)
42599                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
42600         else
42601                 hops_constr.data = NULL;
42602         int8_tArray* hops_vals = (void*) hops->elems;
42603         for (size_t m = 0; m < hops_constr.datalen; m++) {
42604                 int8_tArray hops_conv_12 = hops_vals[m];
42605                 LDKPublicKey hops_conv_12_ref;
42606                 CHECK(hops_conv_12->arr_len == 33);
42607                 memcpy(hops_conv_12_ref.compressed_form, hops_conv_12->elems, 33); FREE(hops_conv_12);
42608                 hops_constr.data[m] = hops_conv_12_ref;
42609         }
42610         FREE(hops);
42611         LDKRouteParameters route_params_conv;
42612         route_params_conv.inner = untag_ptr(route_params);
42613         route_params_conv.is_owned = ptr_is_owned(route_params);
42614         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
42615         route_params_conv.is_owned = false;
42616         LDKNetworkGraph network_graph_conv;
42617         network_graph_conv.inner = untag_ptr(network_graph);
42618         network_graph_conv.is_owned = ptr_is_owned(network_graph);
42619         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42620         network_graph_conv.is_owned = false;
42621         void* logger_ptr = untag_ptr(logger);
42622         CHECK_ACCESS(logger_ptr);
42623         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42624         if (logger_conv.free == LDKLogger_JCalls_free) {
42625                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42626                 LDKLogger_JCalls_cloned(&logger_conv);
42627         }
42628         unsigned char random_seed_bytes_arr[32];
42629         CHECK(random_seed_bytes->arr_len == 32);
42630         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
42631         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
42632         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
42633         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
42634         return tag_ptr(ret_conv, true);
42635 }
42636
42637 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint64_t this_ptr) {
42638         if (!ptr_is_owned(this_ptr)) return;
42639         void* this_ptr_ptr = untag_ptr(this_ptr);
42640         CHECK_ACCESS(this_ptr_ptr);
42641         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
42642         FREE(untag_ptr(this_ptr));
42643         Score_free(this_ptr_conv);
42644 }
42645
42646 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint64_t this_ptr) {
42647         if (!ptr_is_owned(this_ptr)) return;
42648         void* this_ptr_ptr = untag_ptr(this_ptr);
42649         CHECK_ACCESS(this_ptr_ptr);
42650         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
42651         FREE(untag_ptr(this_ptr));
42652         LockableScore_free(this_ptr_conv);
42653 }
42654
42655 void  __attribute__((export_name("TS_WriteableScore_free"))) TS_WriteableScore_free(uint64_t this_ptr) {
42656         if (!ptr_is_owned(this_ptr)) return;
42657         void* this_ptr_ptr = untag_ptr(this_ptr);
42658         CHECK_ACCESS(this_ptr_ptr);
42659         LDKWriteableScore this_ptr_conv = *(LDKWriteableScore*)(this_ptr_ptr);
42660         FREE(untag_ptr(this_ptr));
42661         WriteableScore_free(this_ptr_conv);
42662 }
42663
42664 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint64_t this_obj) {
42665         LDKMultiThreadedLockableScore this_obj_conv;
42666         this_obj_conv.inner = untag_ptr(this_obj);
42667         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42669         MultiThreadedLockableScore_free(this_obj_conv);
42670 }
42671
42672 void  __attribute__((export_name("TS_MultiThreadedScoreLock_free"))) TS_MultiThreadedScoreLock_free(uint64_t this_obj) {
42673         LDKMultiThreadedScoreLock this_obj_conv;
42674         this_obj_conv.inner = untag_ptr(this_obj);
42675         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42677         MultiThreadedScoreLock_free(this_obj_conv);
42678 }
42679
42680 uint64_t  __attribute__((export_name("TS_MultiThreadedScoreLock_as_Score"))) TS_MultiThreadedScoreLock_as_Score(uint64_t this_arg) {
42681         LDKMultiThreadedScoreLock this_arg_conv;
42682         this_arg_conv.inner = untag_ptr(this_arg);
42683         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42685         this_arg_conv.is_owned = false;
42686         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
42687         *ret_ret = MultiThreadedScoreLock_as_Score(&this_arg_conv);
42688         return tag_ptr(ret_ret, true);
42689 }
42690
42691 int8_tArray  __attribute__((export_name("TS_MultiThreadedScoreLock_write"))) TS_MultiThreadedScoreLock_write(uint64_t obj) {
42692         LDKMultiThreadedScoreLock obj_conv;
42693         obj_conv.inner = untag_ptr(obj);
42694         obj_conv.is_owned = ptr_is_owned(obj);
42695         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42696         obj_conv.is_owned = false;
42697         LDKCVec_u8Z ret_var = MultiThreadedScoreLock_write(&obj_conv);
42698         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42699         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42700         CVec_u8Z_free(ret_var);
42701         return ret_arr;
42702 }
42703
42704 uint64_t  __attribute__((export_name("TS_MultiThreadedLockableScore_as_LockableScore"))) TS_MultiThreadedLockableScore_as_LockableScore(uint64_t this_arg) {
42705         LDKMultiThreadedLockableScore this_arg_conv;
42706         this_arg_conv.inner = untag_ptr(this_arg);
42707         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42709         this_arg_conv.is_owned = false;
42710         LDKLockableScore* ret_ret = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
42711         *ret_ret = MultiThreadedLockableScore_as_LockableScore(&this_arg_conv);
42712         return tag_ptr(ret_ret, true);
42713 }
42714
42715 int8_tArray  __attribute__((export_name("TS_MultiThreadedLockableScore_write"))) TS_MultiThreadedLockableScore_write(uint64_t obj) {
42716         LDKMultiThreadedLockableScore obj_conv;
42717         obj_conv.inner = untag_ptr(obj);
42718         obj_conv.is_owned = ptr_is_owned(obj);
42719         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42720         obj_conv.is_owned = false;
42721         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
42722         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42723         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42724         CVec_u8Z_free(ret_var);
42725         return ret_arr;
42726 }
42727
42728 uint64_t  __attribute__((export_name("TS_MultiThreadedLockableScore_as_WriteableScore"))) TS_MultiThreadedLockableScore_as_WriteableScore(uint64_t this_arg) {
42729         LDKMultiThreadedLockableScore this_arg_conv;
42730         this_arg_conv.inner = untag_ptr(this_arg);
42731         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42733         this_arg_conv.is_owned = false;
42734         LDKWriteableScore* ret_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
42735         *ret_ret = MultiThreadedLockableScore_as_WriteableScore(&this_arg_conv);
42736         return tag_ptr(ret_ret, true);
42737 }
42738
42739 uint64_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint64_t score) {
42740         void* score_ptr = untag_ptr(score);
42741         CHECK_ACCESS(score_ptr);
42742         LDKScore score_conv = *(LDKScore*)(score_ptr);
42743         if (score_conv.free == LDKScore_JCalls_free) {
42744                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42745                 LDKScore_JCalls_cloned(&score_conv);
42746         }
42747         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
42748         uint64_t ret_ref = 0;
42749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42750         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42751         return ret_ref;
42752 }
42753
42754 void  __attribute__((export_name("TS_ChannelUsage_free"))) TS_ChannelUsage_free(uint64_t this_obj) {
42755         LDKChannelUsage this_obj_conv;
42756         this_obj_conv.inner = untag_ptr(this_obj);
42757         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42759         ChannelUsage_free(this_obj_conv);
42760 }
42761
42762 int64_t  __attribute__((export_name("TS_ChannelUsage_get_amount_msat"))) TS_ChannelUsage_get_amount_msat(uint64_t this_ptr) {
42763         LDKChannelUsage this_ptr_conv;
42764         this_ptr_conv.inner = untag_ptr(this_ptr);
42765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42767         this_ptr_conv.is_owned = false;
42768         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
42769         return ret_conv;
42770 }
42771
42772 void  __attribute__((export_name("TS_ChannelUsage_set_amount_msat"))) TS_ChannelUsage_set_amount_msat(uint64_t this_ptr, int64_t val) {
42773         LDKChannelUsage this_ptr_conv;
42774         this_ptr_conv.inner = untag_ptr(this_ptr);
42775         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42777         this_ptr_conv.is_owned = false;
42778         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
42779 }
42780
42781 int64_t  __attribute__((export_name("TS_ChannelUsage_get_inflight_htlc_msat"))) TS_ChannelUsage_get_inflight_htlc_msat(uint64_t this_ptr) {
42782         LDKChannelUsage this_ptr_conv;
42783         this_ptr_conv.inner = untag_ptr(this_ptr);
42784         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42786         this_ptr_conv.is_owned = false;
42787         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
42788         return ret_conv;
42789 }
42790
42791 void  __attribute__((export_name("TS_ChannelUsage_set_inflight_htlc_msat"))) TS_ChannelUsage_set_inflight_htlc_msat(uint64_t this_ptr, int64_t val) {
42792         LDKChannelUsage this_ptr_conv;
42793         this_ptr_conv.inner = untag_ptr(this_ptr);
42794         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42796         this_ptr_conv.is_owned = false;
42797         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
42798 }
42799
42800 uint64_t  __attribute__((export_name("TS_ChannelUsage_get_effective_capacity"))) TS_ChannelUsage_get_effective_capacity(uint64_t this_ptr) {
42801         LDKChannelUsage this_ptr_conv;
42802         this_ptr_conv.inner = untag_ptr(this_ptr);
42803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42805         this_ptr_conv.is_owned = false;
42806         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42807         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
42808         uint64_t ret_ref = tag_ptr(ret_copy, true);
42809         return ret_ref;
42810 }
42811
42812 void  __attribute__((export_name("TS_ChannelUsage_set_effective_capacity"))) TS_ChannelUsage_set_effective_capacity(uint64_t this_ptr, uint64_t val) {
42813         LDKChannelUsage this_ptr_conv;
42814         this_ptr_conv.inner = untag_ptr(this_ptr);
42815         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42817         this_ptr_conv.is_owned = false;
42818         void* val_ptr = untag_ptr(val);
42819         CHECK_ACCESS(val_ptr);
42820         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
42821         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(val));
42822         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
42823 }
42824
42825 uint64_t  __attribute__((export_name("TS_ChannelUsage_new"))) TS_ChannelUsage_new(int64_t amount_msat_arg, int64_t inflight_htlc_msat_arg, uint64_t effective_capacity_arg) {
42826         void* effective_capacity_arg_ptr = untag_ptr(effective_capacity_arg);
42827         CHECK_ACCESS(effective_capacity_arg_ptr);
42828         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
42829         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(effective_capacity_arg));
42830         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
42831         uint64_t ret_ref = 0;
42832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42833         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42834         return ret_ref;
42835 }
42836
42837 static inline uint64_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
42838         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
42839         uint64_t ret_ref = 0;
42840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42841         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42842         return ret_ref;
42843 }
42844 int64_t  __attribute__((export_name("TS_ChannelUsage_clone_ptr"))) TS_ChannelUsage_clone_ptr(uint64_t arg) {
42845         LDKChannelUsage arg_conv;
42846         arg_conv.inner = untag_ptr(arg);
42847         arg_conv.is_owned = ptr_is_owned(arg);
42848         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42849         arg_conv.is_owned = false;
42850         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
42851         return ret_conv;
42852 }
42853
42854 uint64_t  __attribute__((export_name("TS_ChannelUsage_clone"))) TS_ChannelUsage_clone(uint64_t orig) {
42855         LDKChannelUsage orig_conv;
42856         orig_conv.inner = untag_ptr(orig);
42857         orig_conv.is_owned = ptr_is_owned(orig);
42858         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42859         orig_conv.is_owned = false;
42860         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
42861         uint64_t ret_ref = 0;
42862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42863         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42864         return ret_ref;
42865 }
42866
42867 void  __attribute__((export_name("TS_FixedPenaltyScorer_free"))) TS_FixedPenaltyScorer_free(uint64_t this_obj) {
42868         LDKFixedPenaltyScorer this_obj_conv;
42869         this_obj_conv.inner = untag_ptr(this_obj);
42870         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42872         FixedPenaltyScorer_free(this_obj_conv);
42873 }
42874
42875 static inline uint64_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
42876         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
42877         uint64_t ret_ref = 0;
42878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42879         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42880         return ret_ref;
42881 }
42882 int64_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone_ptr"))) TS_FixedPenaltyScorer_clone_ptr(uint64_t arg) {
42883         LDKFixedPenaltyScorer arg_conv;
42884         arg_conv.inner = untag_ptr(arg);
42885         arg_conv.is_owned = ptr_is_owned(arg);
42886         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42887         arg_conv.is_owned = false;
42888         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
42889         return ret_conv;
42890 }
42891
42892 uint64_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone"))) TS_FixedPenaltyScorer_clone(uint64_t orig) {
42893         LDKFixedPenaltyScorer orig_conv;
42894         orig_conv.inner = untag_ptr(orig);
42895         orig_conv.is_owned = ptr_is_owned(orig);
42896         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42897         orig_conv.is_owned = false;
42898         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
42899         uint64_t ret_ref = 0;
42900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42901         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42902         return ret_ref;
42903 }
42904
42905 uint64_t  __attribute__((export_name("TS_FixedPenaltyScorer_with_penalty"))) TS_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
42906         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
42907         uint64_t ret_ref = 0;
42908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42910         return ret_ref;
42911 }
42912
42913 uint64_t  __attribute__((export_name("TS_FixedPenaltyScorer_as_Score"))) TS_FixedPenaltyScorer_as_Score(uint64_t this_arg) {
42914         LDKFixedPenaltyScorer this_arg_conv;
42915         this_arg_conv.inner = untag_ptr(this_arg);
42916         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42918         this_arg_conv.is_owned = false;
42919         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
42920         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
42921         return tag_ptr(ret_ret, true);
42922 }
42923
42924 int8_tArray  __attribute__((export_name("TS_FixedPenaltyScorer_write"))) TS_FixedPenaltyScorer_write(uint64_t obj) {
42925         LDKFixedPenaltyScorer obj_conv;
42926         obj_conv.inner = untag_ptr(obj);
42927         obj_conv.is_owned = ptr_is_owned(obj);
42928         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42929         obj_conv.is_owned = false;
42930         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
42931         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42932         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42933         CVec_u8Z_free(ret_var);
42934         return ret_arr;
42935 }
42936
42937 uint64_t  __attribute__((export_name("TS_FixedPenaltyScorer_read"))) TS_FixedPenaltyScorer_read(int8_tArray ser, int64_t arg) {
42938         LDKu8slice ser_ref;
42939         ser_ref.datalen = ser->arr_len;
42940         ser_ref.data = ser->elems;
42941         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
42942         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
42943         FREE(ser);
42944         return tag_ptr(ret_conv, true);
42945 }
42946
42947 void  __attribute__((export_name("TS_ProbabilisticScorer_free"))) TS_ProbabilisticScorer_free(uint64_t this_obj) {
42948         LDKProbabilisticScorer this_obj_conv;
42949         this_obj_conv.inner = untag_ptr(this_obj);
42950         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42952         ProbabilisticScorer_free(this_obj_conv);
42953 }
42954
42955 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_free"))) TS_ProbabilisticScoringParameters_free(uint64_t this_obj) {
42956         LDKProbabilisticScoringParameters this_obj_conv;
42957         this_obj_conv.inner = untag_ptr(this_obj);
42958         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42960         ProbabilisticScoringParameters_free(this_obj_conv);
42961 }
42962
42963 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_base_penalty_msat"))) TS_ProbabilisticScoringParameters_get_base_penalty_msat(uint64_t this_ptr) {
42964         LDKProbabilisticScoringParameters this_ptr_conv;
42965         this_ptr_conv.inner = untag_ptr(this_ptr);
42966         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42968         this_ptr_conv.is_owned = false;
42969         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
42970         return ret_conv;
42971 }
42972
42973 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_base_penalty_msat"))) TS_ProbabilisticScoringParameters_set_base_penalty_msat(uint64_t this_ptr, int64_t val) {
42974         LDKProbabilisticScoringParameters this_ptr_conv;
42975         this_ptr_conv.inner = untag_ptr(this_ptr);
42976         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42978         this_ptr_conv.is_owned = false;
42979         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
42980 }
42981
42982 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(uint64_t this_ptr) {
42983         LDKProbabilisticScoringParameters this_ptr_conv;
42984         this_ptr_conv.inner = untag_ptr(this_ptr);
42985         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42987         this_ptr_conv.is_owned = false;
42988         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
42989         return ret_conv;
42990 }
42991
42992 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat"))) TS_ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(uint64_t this_ptr, int64_t val) {
42993         LDKProbabilisticScoringParameters this_ptr_conv;
42994         this_ptr_conv.inner = untag_ptr(this_ptr);
42995         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42997         this_ptr_conv.is_owned = false;
42998         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
42999 }
43000
43001 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(uint64_t this_ptr) {
43002         LDKProbabilisticScoringParameters this_ptr_conv;
43003         this_ptr_conv.inner = untag_ptr(this_ptr);
43004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43006         this_ptr_conv.is_owned = false;
43007         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
43008         return ret_conv;
43009 }
43010
43011 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(uint64_t this_ptr, int64_t val) {
43012         LDKProbabilisticScoringParameters this_ptr_conv;
43013         this_ptr_conv.inner = untag_ptr(this_ptr);
43014         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43016         this_ptr_conv.is_owned = false;
43017         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
43018 }
43019
43020 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life(uint64_t this_ptr) {
43021         LDKProbabilisticScoringParameters this_ptr_conv;
43022         this_ptr_conv.inner = untag_ptr(this_ptr);
43023         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43025         this_ptr_conv.is_owned = false;
43026         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
43027         return ret_conv;
43028 }
43029
43030 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_set_liquidity_offset_half_life(uint64_t this_ptr, int64_t val) {
43031         LDKProbabilisticScoringParameters this_ptr_conv;
43032         this_ptr_conv.inner = untag_ptr(this_ptr);
43033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43035         this_ptr_conv.is_owned = false;
43036         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
43037 }
43038
43039 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(uint64_t this_ptr) {
43040         LDKProbabilisticScoringParameters this_ptr_conv;
43041         this_ptr_conv.inner = untag_ptr(this_ptr);
43042         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43044         this_ptr_conv.is_owned = false;
43045         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
43046         return ret_conv;
43047 }
43048
43049 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat"))) TS_ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(uint64_t this_ptr, int64_t val) {
43050         LDKProbabilisticScoringParameters this_ptr_conv;
43051         this_ptr_conv.inner = untag_ptr(this_ptr);
43052         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43054         this_ptr_conv.is_owned = false;
43055         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
43056 }
43057
43058 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_anti_probing_penalty_msat"))) TS_ProbabilisticScoringParameters_get_anti_probing_penalty_msat(uint64_t this_ptr) {
43059         LDKProbabilisticScoringParameters this_ptr_conv;
43060         this_ptr_conv.inner = untag_ptr(this_ptr);
43061         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43063         this_ptr_conv.is_owned = false;
43064         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
43065         return ret_conv;
43066 }
43067
43068 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_anti_probing_penalty_msat"))) TS_ProbabilisticScoringParameters_set_anti_probing_penalty_msat(uint64_t this_ptr, int64_t val) {
43069         LDKProbabilisticScoringParameters this_ptr_conv;
43070         this_ptr_conv.inner = untag_ptr(this_ptr);
43071         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43073         this_ptr_conv.is_owned = false;
43074         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
43075 }
43076
43077 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_considered_impossible_penalty_msat"))) TS_ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(uint64_t this_ptr) {
43078         LDKProbabilisticScoringParameters this_ptr_conv;
43079         this_ptr_conv.inner = untag_ptr(this_ptr);
43080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43082         this_ptr_conv.is_owned = false;
43083         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
43084         return ret_conv;
43085 }
43086
43087 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_considered_impossible_penalty_msat"))) TS_ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(uint64_t this_ptr, int64_t val) {
43088         LDKProbabilisticScoringParameters this_ptr_conv;
43089         this_ptr_conv.inner = untag_ptr(this_ptr);
43090         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43092         this_ptr_conv.is_owned = false;
43093         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
43094 }
43095
43096 static inline uint64_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
43097         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
43098         uint64_t ret_ref = 0;
43099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43100         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43101         return ret_ref;
43102 }
43103 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone_ptr"))) TS_ProbabilisticScoringParameters_clone_ptr(uint64_t arg) {
43104         LDKProbabilisticScoringParameters arg_conv;
43105         arg_conv.inner = untag_ptr(arg);
43106         arg_conv.is_owned = ptr_is_owned(arg);
43107         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43108         arg_conv.is_owned = false;
43109         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
43110         return ret_conv;
43111 }
43112
43113 uint64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone"))) TS_ProbabilisticScoringParameters_clone(uint64_t orig) {
43114         LDKProbabilisticScoringParameters orig_conv;
43115         orig_conv.inner = untag_ptr(orig);
43116         orig_conv.is_owned = ptr_is_owned(orig);
43117         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43118         orig_conv.is_owned = false;
43119         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
43120         uint64_t ret_ref = 0;
43121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43122         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43123         return ret_ref;
43124 }
43125
43126 uint64_t  __attribute__((export_name("TS_ProbabilisticScorer_new"))) TS_ProbabilisticScorer_new(uint64_t params, uint64_t network_graph, uint64_t logger) {
43127         LDKProbabilisticScoringParameters params_conv;
43128         params_conv.inner = untag_ptr(params);
43129         params_conv.is_owned = ptr_is_owned(params);
43130         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
43131         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
43132         LDKNetworkGraph network_graph_conv;
43133         network_graph_conv.inner = untag_ptr(network_graph);
43134         network_graph_conv.is_owned = ptr_is_owned(network_graph);
43135         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
43136         network_graph_conv.is_owned = false;
43137         void* logger_ptr = untag_ptr(logger);
43138         CHECK_ACCESS(logger_ptr);
43139         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43140         if (logger_conv.free == LDKLogger_JCalls_free) {
43141                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43142                 LDKLogger_JCalls_cloned(&logger_conv);
43143         }
43144         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
43145         uint64_t ret_ref = 0;
43146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43147         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43148         return ret_ref;
43149 }
43150
43151 void  __attribute__((export_name("TS_ProbabilisticScorer_debug_log_liquidity_stats"))) TS_ProbabilisticScorer_debug_log_liquidity_stats(uint64_t this_arg) {
43152         LDKProbabilisticScorer this_arg_conv;
43153         this_arg_conv.inner = untag_ptr(this_arg);
43154         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43156         this_arg_conv.is_owned = false;
43157         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
43158 }
43159
43160 uint64_t  __attribute__((export_name("TS_ProbabilisticScorer_estimated_channel_liquidity_range"))) TS_ProbabilisticScorer_estimated_channel_liquidity_range(uint64_t this_arg, int64_t scid, uint64_t target) {
43161         LDKProbabilisticScorer this_arg_conv;
43162         this_arg_conv.inner = untag_ptr(this_arg);
43163         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43165         this_arg_conv.is_owned = false;
43166         LDKNodeId target_conv;
43167         target_conv.inner = untag_ptr(target);
43168         target_conv.is_owned = ptr_is_owned(target);
43169         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
43170         target_conv.is_owned = false;
43171         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
43172         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
43173         uint64_t ret_ref = tag_ptr(ret_copy, true);
43174         return ret_ref;
43175 }
43176
43177 void  __attribute__((export_name("TS_ProbabilisticScorer_add_banned"))) TS_ProbabilisticScorer_add_banned(uint64_t this_arg, uint64_t node_id) {
43178         LDKProbabilisticScorer this_arg_conv;
43179         this_arg_conv.inner = untag_ptr(this_arg);
43180         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43182         this_arg_conv.is_owned = false;
43183         LDKNodeId node_id_conv;
43184         node_id_conv.inner = untag_ptr(node_id);
43185         node_id_conv.is_owned = ptr_is_owned(node_id);
43186         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43187         node_id_conv.is_owned = false;
43188         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
43189 }
43190
43191 void  __attribute__((export_name("TS_ProbabilisticScorer_remove_banned"))) TS_ProbabilisticScorer_remove_banned(uint64_t this_arg, uint64_t node_id) {
43192         LDKProbabilisticScorer this_arg_conv;
43193         this_arg_conv.inner = untag_ptr(this_arg);
43194         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43196         this_arg_conv.is_owned = false;
43197         LDKNodeId node_id_conv;
43198         node_id_conv.inner = untag_ptr(node_id);
43199         node_id_conv.is_owned = ptr_is_owned(node_id);
43200         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43201         node_id_conv.is_owned = false;
43202         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
43203 }
43204
43205 void  __attribute__((export_name("TS_ProbabilisticScorer_set_manual_penalty"))) TS_ProbabilisticScorer_set_manual_penalty(uint64_t this_arg, uint64_t node_id, int64_t penalty) {
43206         LDKProbabilisticScorer this_arg_conv;
43207         this_arg_conv.inner = untag_ptr(this_arg);
43208         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43210         this_arg_conv.is_owned = false;
43211         LDKNodeId node_id_conv;
43212         node_id_conv.inner = untag_ptr(node_id);
43213         node_id_conv.is_owned = ptr_is_owned(node_id);
43214         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43215         node_id_conv.is_owned = false;
43216         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
43217 }
43218
43219 void  __attribute__((export_name("TS_ProbabilisticScorer_remove_manual_penalty"))) TS_ProbabilisticScorer_remove_manual_penalty(uint64_t this_arg, uint64_t node_id) {
43220         LDKProbabilisticScorer this_arg_conv;
43221         this_arg_conv.inner = untag_ptr(this_arg);
43222         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43224         this_arg_conv.is_owned = false;
43225         LDKNodeId node_id_conv;
43226         node_id_conv.inner = untag_ptr(node_id);
43227         node_id_conv.is_owned = ptr_is_owned(node_id);
43228         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43229         node_id_conv.is_owned = false;
43230         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
43231 }
43232
43233 void  __attribute__((export_name("TS_ProbabilisticScorer_clear_manual_penalties"))) TS_ProbabilisticScorer_clear_manual_penalties(uint64_t this_arg) {
43234         LDKProbabilisticScorer this_arg_conv;
43235         this_arg_conv.inner = untag_ptr(this_arg);
43236         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43238         this_arg_conv.is_owned = false;
43239         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
43240 }
43241
43242 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_add_banned_from_list"))) TS_ProbabilisticScoringParameters_add_banned_from_list(uint64_t this_arg, uint64_tArray node_ids) {
43243         LDKProbabilisticScoringParameters this_arg_conv;
43244         this_arg_conv.inner = untag_ptr(this_arg);
43245         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43247         this_arg_conv.is_owned = false;
43248         LDKCVec_NodeIdZ node_ids_constr;
43249         node_ids_constr.datalen = node_ids->arr_len;
43250         if (node_ids_constr.datalen > 0)
43251                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
43252         else
43253                 node_ids_constr.data = NULL;
43254         uint64_t* node_ids_vals = node_ids->elems;
43255         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
43256                 uint64_t node_ids_conv_8 = node_ids_vals[i];
43257                 LDKNodeId node_ids_conv_8_conv;
43258                 node_ids_conv_8_conv.inner = untag_ptr(node_ids_conv_8);
43259                 node_ids_conv_8_conv.is_owned = ptr_is_owned(node_ids_conv_8);
43260                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
43261                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
43262                 node_ids_constr.data[i] = node_ids_conv_8_conv;
43263         }
43264         FREE(node_ids);
43265         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
43266 }
43267
43268 uint64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_default"))) TS_ProbabilisticScoringParameters_default() {
43269         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
43270         uint64_t ret_ref = 0;
43271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43272         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43273         return ret_ref;
43274 }
43275
43276 uint64_t  __attribute__((export_name("TS_ProbabilisticScorer_as_Score"))) TS_ProbabilisticScorer_as_Score(uint64_t this_arg) {
43277         LDKProbabilisticScorer this_arg_conv;
43278         this_arg_conv.inner = untag_ptr(this_arg);
43279         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43281         this_arg_conv.is_owned = false;
43282         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
43283         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
43284         return tag_ptr(ret_ret, true);
43285 }
43286
43287 int8_tArray  __attribute__((export_name("TS_ProbabilisticScorer_write"))) TS_ProbabilisticScorer_write(uint64_t obj) {
43288         LDKProbabilisticScorer obj_conv;
43289         obj_conv.inner = untag_ptr(obj);
43290         obj_conv.is_owned = ptr_is_owned(obj);
43291         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43292         obj_conv.is_owned = false;
43293         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
43294         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
43295         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
43296         CVec_u8Z_free(ret_var);
43297         return ret_arr;
43298 }
43299
43300 uint64_t  __attribute__((export_name("TS_ProbabilisticScorer_read"))) TS_ProbabilisticScorer_read(int8_tArray ser, uint64_t arg_a, uint64_t arg_b, uint64_t arg_c) {
43301         LDKu8slice ser_ref;
43302         ser_ref.datalen = ser->arr_len;
43303         ser_ref.data = ser->elems;
43304         LDKProbabilisticScoringParameters arg_a_conv;
43305         arg_a_conv.inner = untag_ptr(arg_a);
43306         arg_a_conv.is_owned = ptr_is_owned(arg_a);
43307         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
43308         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
43309         LDKNetworkGraph arg_b_conv;
43310         arg_b_conv.inner = untag_ptr(arg_b);
43311         arg_b_conv.is_owned = ptr_is_owned(arg_b);
43312         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
43313         arg_b_conv.is_owned = false;
43314         void* arg_c_ptr = untag_ptr(arg_c);
43315         CHECK_ACCESS(arg_c_ptr);
43316         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
43317         if (arg_c_conv.free == LDKLogger_JCalls_free) {
43318                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43319                 LDKLogger_JCalls_cloned(&arg_c_conv);
43320         }
43321         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
43322         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
43323         FREE(ser);
43324         return tag_ptr(ret_conv, true);
43325 }
43326
43327 void  __attribute__((export_name("TS_BlindedRoute_free"))) TS_BlindedRoute_free(uint64_t this_obj) {
43328         LDKBlindedRoute this_obj_conv;
43329         this_obj_conv.inner = untag_ptr(this_obj);
43330         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43332         BlindedRoute_free(this_obj_conv);
43333 }
43334
43335 void  __attribute__((export_name("TS_BlindedHop_free"))) TS_BlindedHop_free(uint64_t this_obj) {
43336         LDKBlindedHop this_obj_conv;
43337         this_obj_conv.inner = untag_ptr(this_obj);
43338         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43340         BlindedHop_free(this_obj_conv);
43341 }
43342
43343 uint64_t  __attribute__((export_name("TS_BlindedRoute_new"))) TS_BlindedRoute_new(ptrArray node_pks, uint64_t keys_manager) {
43344         LDKCVec_PublicKeyZ node_pks_constr;
43345         node_pks_constr.datalen = node_pks->arr_len;
43346         if (node_pks_constr.datalen > 0)
43347                 node_pks_constr.data = MALLOC(node_pks_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
43348         else
43349                 node_pks_constr.data = NULL;
43350         int8_tArray* node_pks_vals = (void*) node_pks->elems;
43351         for (size_t m = 0; m < node_pks_constr.datalen; m++) {
43352                 int8_tArray node_pks_conv_12 = node_pks_vals[m];
43353                 LDKPublicKey node_pks_conv_12_ref;
43354                 CHECK(node_pks_conv_12->arr_len == 33);
43355                 memcpy(node_pks_conv_12_ref.compressed_form, node_pks_conv_12->elems, 33); FREE(node_pks_conv_12);
43356                 node_pks_constr.data[m] = node_pks_conv_12_ref;
43357         }
43358         FREE(node_pks);
43359         void* keys_manager_ptr = untag_ptr(keys_manager);
43360         if (ptr_is_owned(keys_manager)) { CHECK_ACCESS(keys_manager_ptr); }
43361         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
43362         LDKCResult_BlindedRouteNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteNoneZ), "LDKCResult_BlindedRouteNoneZ");
43363         *ret_conv = BlindedRoute_new(node_pks_constr, keys_manager_conv);
43364         return tag_ptr(ret_conv, true);
43365 }
43366
43367 int8_tArray  __attribute__((export_name("TS_BlindedRoute_write"))) TS_BlindedRoute_write(uint64_t obj) {
43368         LDKBlindedRoute obj_conv;
43369         obj_conv.inner = untag_ptr(obj);
43370         obj_conv.is_owned = ptr_is_owned(obj);
43371         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43372         obj_conv.is_owned = false;
43373         LDKCVec_u8Z ret_var = BlindedRoute_write(&obj_conv);
43374         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
43375         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
43376         CVec_u8Z_free(ret_var);
43377         return ret_arr;
43378 }
43379
43380 uint64_t  __attribute__((export_name("TS_BlindedRoute_read"))) TS_BlindedRoute_read(int8_tArray ser) {
43381         LDKu8slice ser_ref;
43382         ser_ref.datalen = ser->arr_len;
43383         ser_ref.data = ser->elems;
43384         LDKCResult_BlindedRouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteDecodeErrorZ), "LDKCResult_BlindedRouteDecodeErrorZ");
43385         *ret_conv = BlindedRoute_read(ser_ref);
43386         FREE(ser);
43387         return tag_ptr(ret_conv, true);
43388 }
43389
43390 int8_tArray  __attribute__((export_name("TS_BlindedHop_write"))) TS_BlindedHop_write(uint64_t obj) {
43391         LDKBlindedHop obj_conv;
43392         obj_conv.inner = untag_ptr(obj);
43393         obj_conv.is_owned = ptr_is_owned(obj);
43394         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43395         obj_conv.is_owned = false;
43396         LDKCVec_u8Z ret_var = BlindedHop_write(&obj_conv);
43397         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
43398         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
43399         CVec_u8Z_free(ret_var);
43400         return ret_arr;
43401 }
43402
43403 uint64_t  __attribute__((export_name("TS_BlindedHop_read"))) TS_BlindedHop_read(int8_tArray ser) {
43404         LDKu8slice ser_ref;
43405         ser_ref.datalen = ser->arr_len;
43406         ser_ref.data = ser->elems;
43407         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
43408         *ret_conv = BlindedHop_read(ser_ref);
43409         FREE(ser);
43410         return tag_ptr(ret_conv, true);
43411 }
43412
43413 void  __attribute__((export_name("TS_OnionMessenger_free"))) TS_OnionMessenger_free(uint64_t this_obj) {
43414         LDKOnionMessenger this_obj_conv;
43415         this_obj_conv.inner = untag_ptr(this_obj);
43416         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43418         OnionMessenger_free(this_obj_conv);
43419 }
43420
43421 void  __attribute__((export_name("TS_Destination_free"))) TS_Destination_free(uint64_t this_ptr) {
43422         if (!ptr_is_owned(this_ptr)) return;
43423         void* this_ptr_ptr = untag_ptr(this_ptr);
43424         CHECK_ACCESS(this_ptr_ptr);
43425         LDKDestination this_ptr_conv = *(LDKDestination*)(this_ptr_ptr);
43426         FREE(untag_ptr(this_ptr));
43427         Destination_free(this_ptr_conv);
43428 }
43429
43430 uint64_t  __attribute__((export_name("TS_Destination_node"))) TS_Destination_node(int8_tArray a) {
43431         LDKPublicKey a_ref;
43432         CHECK(a->arr_len == 33);
43433         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
43434         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
43435         *ret_copy = Destination_node(a_ref);
43436         uint64_t ret_ref = tag_ptr(ret_copy, true);
43437         return ret_ref;
43438 }
43439
43440 uint64_t  __attribute__((export_name("TS_Destination_blinded_route"))) TS_Destination_blinded_route(uint64_t a) {
43441         LDKBlindedRoute a_conv;
43442         a_conv.inner = untag_ptr(a);
43443         a_conv.is_owned = ptr_is_owned(a);
43444         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43445         // WARNING: we need a move here but no clone is available for LDKBlindedRoute
43446         
43447         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
43448         *ret_copy = Destination_blinded_route(a_conv);
43449         uint64_t ret_ref = tag_ptr(ret_copy, true);
43450         return ret_ref;
43451 }
43452
43453 void  __attribute__((export_name("TS_SendError_free"))) TS_SendError_free(uint64_t this_ptr) {
43454         if (!ptr_is_owned(this_ptr)) return;
43455         void* this_ptr_ptr = untag_ptr(this_ptr);
43456         CHECK_ACCESS(this_ptr_ptr);
43457         LDKSendError this_ptr_conv = *(LDKSendError*)(this_ptr_ptr);
43458         FREE(untag_ptr(this_ptr));
43459         SendError_free(this_ptr_conv);
43460 }
43461
43462 static inline uint64_t SendError_clone_ptr(LDKSendError *NONNULL_PTR arg) {
43463         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
43464         *ret_copy = SendError_clone(arg);
43465         uint64_t ret_ref = tag_ptr(ret_copy, true);
43466         return ret_ref;
43467 }
43468 int64_t  __attribute__((export_name("TS_SendError_clone_ptr"))) TS_SendError_clone_ptr(uint64_t arg) {
43469         LDKSendError* arg_conv = (LDKSendError*)untag_ptr(arg);
43470         int64_t ret_conv = SendError_clone_ptr(arg_conv);
43471         return ret_conv;
43472 }
43473
43474 uint64_t  __attribute__((export_name("TS_SendError_clone"))) TS_SendError_clone(uint64_t orig) {
43475         LDKSendError* orig_conv = (LDKSendError*)untag_ptr(orig);
43476         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
43477         *ret_copy = SendError_clone(orig_conv);
43478         uint64_t ret_ref = tag_ptr(ret_copy, true);
43479         return ret_ref;
43480 }
43481
43482 uint64_t  __attribute__((export_name("TS_SendError_secp256k1"))) TS_SendError_secp256k1(uint32_t a) {
43483         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_js(a);
43484         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
43485         *ret_copy = SendError_secp256k1(a_conv);
43486         uint64_t ret_ref = tag_ptr(ret_copy, true);
43487         return ret_ref;
43488 }
43489
43490 uint64_t  __attribute__((export_name("TS_SendError_too_big_packet"))) TS_SendError_too_big_packet() {
43491         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
43492         *ret_copy = SendError_too_big_packet();
43493         uint64_t ret_ref = tag_ptr(ret_copy, true);
43494         return ret_ref;
43495 }
43496
43497 uint64_t  __attribute__((export_name("TS_SendError_too_few_blinded_hops"))) TS_SendError_too_few_blinded_hops() {
43498         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
43499         *ret_copy = SendError_too_few_blinded_hops();
43500         uint64_t ret_ref = tag_ptr(ret_copy, true);
43501         return ret_ref;
43502 }
43503
43504 uint64_t  __attribute__((export_name("TS_SendError_invalid_first_hop"))) TS_SendError_invalid_first_hop() {
43505         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
43506         *ret_copy = SendError_invalid_first_hop();
43507         uint64_t ret_ref = tag_ptr(ret_copy, true);
43508         return ret_ref;
43509 }
43510
43511 uint64_t  __attribute__((export_name("TS_SendError_buffer_full"))) TS_SendError_buffer_full() {
43512         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
43513         *ret_copy = SendError_buffer_full();
43514         uint64_t ret_ref = tag_ptr(ret_copy, true);
43515         return ret_ref;
43516 }
43517
43518 uint64_t  __attribute__((export_name("TS_OnionMessenger_new"))) TS_OnionMessenger_new(uint64_t keys_manager, uint64_t logger) {
43519         void* keys_manager_ptr = untag_ptr(keys_manager);
43520         CHECK_ACCESS(keys_manager_ptr);
43521         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
43522         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
43523                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43524                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
43525         }
43526         void* logger_ptr = untag_ptr(logger);
43527         CHECK_ACCESS(logger_ptr);
43528         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43529         if (logger_conv.free == LDKLogger_JCalls_free) {
43530                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43531                 LDKLogger_JCalls_cloned(&logger_conv);
43532         }
43533         LDKOnionMessenger ret_var = OnionMessenger_new(keys_manager_conv, logger_conv);
43534         uint64_t ret_ref = 0;
43535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43536         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43537         return ret_ref;
43538 }
43539
43540 uint64_t  __attribute__((export_name("TS_OnionMessenger_send_onion_message"))) TS_OnionMessenger_send_onion_message(uint64_t this_arg, ptrArray intermediate_nodes, uint64_t destination, uint64_t reply_path) {
43541         LDKOnionMessenger this_arg_conv;
43542         this_arg_conv.inner = untag_ptr(this_arg);
43543         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43545         this_arg_conv.is_owned = false;
43546         LDKCVec_PublicKeyZ intermediate_nodes_constr;
43547         intermediate_nodes_constr.datalen = intermediate_nodes->arr_len;
43548         if (intermediate_nodes_constr.datalen > 0)
43549                 intermediate_nodes_constr.data = MALLOC(intermediate_nodes_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
43550         else
43551                 intermediate_nodes_constr.data = NULL;
43552         int8_tArray* intermediate_nodes_vals = (void*) intermediate_nodes->elems;
43553         for (size_t m = 0; m < intermediate_nodes_constr.datalen; m++) {
43554                 int8_tArray intermediate_nodes_conv_12 = intermediate_nodes_vals[m];
43555                 LDKPublicKey intermediate_nodes_conv_12_ref;
43556                 CHECK(intermediate_nodes_conv_12->arr_len == 33);
43557                 memcpy(intermediate_nodes_conv_12_ref.compressed_form, intermediate_nodes_conv_12->elems, 33); FREE(intermediate_nodes_conv_12);
43558                 intermediate_nodes_constr.data[m] = intermediate_nodes_conv_12_ref;
43559         }
43560         FREE(intermediate_nodes);
43561         void* destination_ptr = untag_ptr(destination);
43562         CHECK_ACCESS(destination_ptr);
43563         LDKDestination destination_conv = *(LDKDestination*)(destination_ptr);
43564         // WARNING: we may need a move here but no clone is available for LDKDestination
43565         LDKBlindedRoute reply_path_conv;
43566         reply_path_conv.inner = untag_ptr(reply_path);
43567         reply_path_conv.is_owned = ptr_is_owned(reply_path);
43568         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
43569         reply_path_conv.is_owned = false;
43570         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
43571         *ret_conv = OnionMessenger_send_onion_message(&this_arg_conv, intermediate_nodes_constr, destination_conv, reply_path_conv);
43572         return tag_ptr(ret_conv, true);
43573 }
43574
43575 uint64_t  __attribute__((export_name("TS_OnionMessenger_as_OnionMessageHandler"))) TS_OnionMessenger_as_OnionMessageHandler(uint64_t this_arg) {
43576         LDKOnionMessenger this_arg_conv;
43577         this_arg_conv.inner = untag_ptr(this_arg);
43578         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43580         this_arg_conv.is_owned = false;
43581         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
43582         *ret_ret = OnionMessenger_as_OnionMessageHandler(&this_arg_conv);
43583         return tag_ptr(ret_ret, true);
43584 }
43585
43586 uint64_t  __attribute__((export_name("TS_OnionMessenger_as_OnionMessageProvider"))) TS_OnionMessenger_as_OnionMessageProvider(uint64_t this_arg) {
43587         LDKOnionMessenger this_arg_conv;
43588         this_arg_conv.inner = untag_ptr(this_arg);
43589         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43591         this_arg_conv.is_owned = false;
43592         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
43593         *ret_ret = OnionMessenger_as_OnionMessageProvider(&this_arg_conv);
43594         return tag_ptr(ret_ret, true);
43595 }
43596
43597 void  __attribute__((export_name("TS_ParseError_free"))) TS_ParseError_free(uint64_t this_ptr) {
43598         if (!ptr_is_owned(this_ptr)) return;
43599         void* this_ptr_ptr = untag_ptr(this_ptr);
43600         CHECK_ACCESS(this_ptr_ptr);
43601         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
43602         FREE(untag_ptr(this_ptr));
43603         ParseError_free(this_ptr_conv);
43604 }
43605
43606 static inline uint64_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
43607         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43608         *ret_copy = ParseError_clone(arg);
43609         uint64_t ret_ref = tag_ptr(ret_copy, true);
43610         return ret_ref;
43611 }
43612 int64_t  __attribute__((export_name("TS_ParseError_clone_ptr"))) TS_ParseError_clone_ptr(uint64_t arg) {
43613         LDKParseError* arg_conv = (LDKParseError*)untag_ptr(arg);
43614         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
43615         return ret_conv;
43616 }
43617
43618 uint64_t  __attribute__((export_name("TS_ParseError_clone"))) TS_ParseError_clone(uint64_t orig) {
43619         LDKParseError* orig_conv = (LDKParseError*)untag_ptr(orig);
43620         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43621         *ret_copy = ParseError_clone(orig_conv);
43622         uint64_t ret_ref = tag_ptr(ret_copy, true);
43623         return ret_ref;
43624 }
43625
43626 uint64_t  __attribute__((export_name("TS_ParseError_bech32_error"))) TS_ParseError_bech32_error(uint64_t a) {
43627         void* a_ptr = untag_ptr(a);
43628         CHECK_ACCESS(a_ptr);
43629         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
43630         a_conv = Bech32Error_clone((LDKBech32Error*)untag_ptr(a));
43631         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43632         *ret_copy = ParseError_bech32_error(a_conv);
43633         uint64_t ret_ref = tag_ptr(ret_copy, true);
43634         return ret_ref;
43635 }
43636
43637 uint64_t  __attribute__((export_name("TS_ParseError_parse_amount_error"))) TS_ParseError_parse_amount_error(int32_t a) {
43638         
43639         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43640         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
43641         uint64_t ret_ref = tag_ptr(ret_copy, true);
43642         return ret_ref;
43643 }
43644
43645 uint64_t  __attribute__((export_name("TS_ParseError_malformed_signature"))) TS_ParseError_malformed_signature(uint32_t a) {
43646         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_js(a);
43647         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43648         *ret_copy = ParseError_malformed_signature(a_conv);
43649         uint64_t ret_ref = tag_ptr(ret_copy, true);
43650         return ret_ref;
43651 }
43652
43653 uint64_t  __attribute__((export_name("TS_ParseError_bad_prefix"))) TS_ParseError_bad_prefix() {
43654         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43655         *ret_copy = ParseError_bad_prefix();
43656         uint64_t ret_ref = tag_ptr(ret_copy, true);
43657         return ret_ref;
43658 }
43659
43660 uint64_t  __attribute__((export_name("TS_ParseError_unknown_currency"))) TS_ParseError_unknown_currency() {
43661         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43662         *ret_copy = ParseError_unknown_currency();
43663         uint64_t ret_ref = tag_ptr(ret_copy, true);
43664         return ret_ref;
43665 }
43666
43667 uint64_t  __attribute__((export_name("TS_ParseError_unknown_si_prefix"))) TS_ParseError_unknown_si_prefix() {
43668         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43669         *ret_copy = ParseError_unknown_si_prefix();
43670         uint64_t ret_ref = tag_ptr(ret_copy, true);
43671         return ret_ref;
43672 }
43673
43674 uint64_t  __attribute__((export_name("TS_ParseError_malformed_hrp"))) TS_ParseError_malformed_hrp() {
43675         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43676         *ret_copy = ParseError_malformed_hrp();
43677         uint64_t ret_ref = tag_ptr(ret_copy, true);
43678         return ret_ref;
43679 }
43680
43681 uint64_t  __attribute__((export_name("TS_ParseError_too_short_data_part"))) TS_ParseError_too_short_data_part() {
43682         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43683         *ret_copy = ParseError_too_short_data_part();
43684         uint64_t ret_ref = tag_ptr(ret_copy, true);
43685         return ret_ref;
43686 }
43687
43688 uint64_t  __attribute__((export_name("TS_ParseError_unexpected_end_of_tagged_fields"))) TS_ParseError_unexpected_end_of_tagged_fields() {
43689         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43690         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
43691         uint64_t ret_ref = tag_ptr(ret_copy, true);
43692         return ret_ref;
43693 }
43694
43695 uint64_t  __attribute__((export_name("TS_ParseError_description_decode_error"))) TS_ParseError_description_decode_error(int32_t a) {
43696         
43697         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43698         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
43699         uint64_t ret_ref = tag_ptr(ret_copy, true);
43700         return ret_ref;
43701 }
43702
43703 uint64_t  __attribute__((export_name("TS_ParseError_padding_error"))) TS_ParseError_padding_error() {
43704         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43705         *ret_copy = ParseError_padding_error();
43706         uint64_t ret_ref = tag_ptr(ret_copy, true);
43707         return ret_ref;
43708 }
43709
43710 uint64_t  __attribute__((export_name("TS_ParseError_integer_overflow_error"))) TS_ParseError_integer_overflow_error() {
43711         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43712         *ret_copy = ParseError_integer_overflow_error();
43713         uint64_t ret_ref = tag_ptr(ret_copy, true);
43714         return ret_ref;
43715 }
43716
43717 uint64_t  __attribute__((export_name("TS_ParseError_invalid_seg_wit_program_length"))) TS_ParseError_invalid_seg_wit_program_length() {
43718         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43719         *ret_copy = ParseError_invalid_seg_wit_program_length();
43720         uint64_t ret_ref = tag_ptr(ret_copy, true);
43721         return ret_ref;
43722 }
43723
43724 uint64_t  __attribute__((export_name("TS_ParseError_invalid_pub_key_hash_length"))) TS_ParseError_invalid_pub_key_hash_length() {
43725         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43726         *ret_copy = ParseError_invalid_pub_key_hash_length();
43727         uint64_t ret_ref = tag_ptr(ret_copy, true);
43728         return ret_ref;
43729 }
43730
43731 uint64_t  __attribute__((export_name("TS_ParseError_invalid_script_hash_length"))) TS_ParseError_invalid_script_hash_length() {
43732         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43733         *ret_copy = ParseError_invalid_script_hash_length();
43734         uint64_t ret_ref = tag_ptr(ret_copy, true);
43735         return ret_ref;
43736 }
43737
43738 uint64_t  __attribute__((export_name("TS_ParseError_invalid_recovery_id"))) TS_ParseError_invalid_recovery_id() {
43739         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43740         *ret_copy = ParseError_invalid_recovery_id();
43741         uint64_t ret_ref = tag_ptr(ret_copy, true);
43742         return ret_ref;
43743 }
43744
43745 uint64_t  __attribute__((export_name("TS_ParseError_invalid_slice_length"))) TS_ParseError_invalid_slice_length(jstring a) {
43746         LDKStr a_conv = str_ref_to_owned_c(a);
43747         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43748         *ret_copy = ParseError_invalid_slice_length(a_conv);
43749         uint64_t ret_ref = tag_ptr(ret_copy, true);
43750         return ret_ref;
43751 }
43752
43753 uint64_t  __attribute__((export_name("TS_ParseError_skip"))) TS_ParseError_skip() {
43754         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43755         *ret_copy = ParseError_skip();
43756         uint64_t ret_ref = tag_ptr(ret_copy, true);
43757         return ret_ref;
43758 }
43759
43760 void  __attribute__((export_name("TS_ParseOrSemanticError_free"))) TS_ParseOrSemanticError_free(uint64_t this_ptr) {
43761         if (!ptr_is_owned(this_ptr)) return;
43762         void* this_ptr_ptr = untag_ptr(this_ptr);
43763         CHECK_ACCESS(this_ptr_ptr);
43764         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
43765         FREE(untag_ptr(this_ptr));
43766         ParseOrSemanticError_free(this_ptr_conv);
43767 }
43768
43769 static inline uint64_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
43770         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43771         *ret_copy = ParseOrSemanticError_clone(arg);
43772         uint64_t ret_ref = tag_ptr(ret_copy, true);
43773         return ret_ref;
43774 }
43775 int64_t  __attribute__((export_name("TS_ParseOrSemanticError_clone_ptr"))) TS_ParseOrSemanticError_clone_ptr(uint64_t arg) {
43776         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)untag_ptr(arg);
43777         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
43778         return ret_conv;
43779 }
43780
43781 uint64_t  __attribute__((export_name("TS_ParseOrSemanticError_clone"))) TS_ParseOrSemanticError_clone(uint64_t orig) {
43782         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)untag_ptr(orig);
43783         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43784         *ret_copy = ParseOrSemanticError_clone(orig_conv);
43785         uint64_t ret_ref = tag_ptr(ret_copy, true);
43786         return ret_ref;
43787 }
43788
43789 uint64_t  __attribute__((export_name("TS_ParseOrSemanticError_parse_error"))) TS_ParseOrSemanticError_parse_error(uint64_t a) {
43790         void* a_ptr = untag_ptr(a);
43791         CHECK_ACCESS(a_ptr);
43792         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
43793         a_conv = ParseError_clone((LDKParseError*)untag_ptr(a));
43794         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43795         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
43796         uint64_t ret_ref = tag_ptr(ret_copy, true);
43797         return ret_ref;
43798 }
43799
43800 uint64_t  __attribute__((export_name("TS_ParseOrSemanticError_semantic_error"))) TS_ParseOrSemanticError_semantic_error(uint32_t a) {
43801         LDKSemanticError a_conv = LDKSemanticError_from_js(a);
43802         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43803         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
43804         uint64_t ret_ref = tag_ptr(ret_copy, true);
43805         return ret_ref;
43806 }
43807
43808 void  __attribute__((export_name("TS_Invoice_free"))) TS_Invoice_free(uint64_t this_obj) {
43809         LDKInvoice this_obj_conv;
43810         this_obj_conv.inner = untag_ptr(this_obj);
43811         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43813         Invoice_free(this_obj_conv);
43814 }
43815
43816 jboolean  __attribute__((export_name("TS_Invoice_eq"))) TS_Invoice_eq(uint64_t a, uint64_t b) {
43817         LDKInvoice a_conv;
43818         a_conv.inner = untag_ptr(a);
43819         a_conv.is_owned = ptr_is_owned(a);
43820         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43821         a_conv.is_owned = false;
43822         LDKInvoice b_conv;
43823         b_conv.inner = untag_ptr(b);
43824         b_conv.is_owned = ptr_is_owned(b);
43825         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43826         b_conv.is_owned = false;
43827         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
43828         return ret_conv;
43829 }
43830
43831 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
43832         LDKInvoice ret_var = Invoice_clone(arg);
43833         uint64_t ret_ref = 0;
43834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43835         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43836         return ret_ref;
43837 }
43838 int64_t  __attribute__((export_name("TS_Invoice_clone_ptr"))) TS_Invoice_clone_ptr(uint64_t arg) {
43839         LDKInvoice arg_conv;
43840         arg_conv.inner = untag_ptr(arg);
43841         arg_conv.is_owned = ptr_is_owned(arg);
43842         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43843         arg_conv.is_owned = false;
43844         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
43845         return ret_conv;
43846 }
43847
43848 uint64_t  __attribute__((export_name("TS_Invoice_clone"))) TS_Invoice_clone(uint64_t orig) {
43849         LDKInvoice orig_conv;
43850         orig_conv.inner = untag_ptr(orig);
43851         orig_conv.is_owned = ptr_is_owned(orig);
43852         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43853         orig_conv.is_owned = false;
43854         LDKInvoice ret_var = Invoice_clone(&orig_conv);
43855         uint64_t ret_ref = 0;
43856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43857         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43858         return ret_ref;
43859 }
43860
43861 int64_t  __attribute__((export_name("TS_Invoice_hash"))) TS_Invoice_hash(uint64_t o) {
43862         LDKInvoice o_conv;
43863         o_conv.inner = untag_ptr(o);
43864         o_conv.is_owned = ptr_is_owned(o);
43865         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43866         o_conv.is_owned = false;
43867         int64_t ret_conv = Invoice_hash(&o_conv);
43868         return ret_conv;
43869 }
43870
43871 void  __attribute__((export_name("TS_SignedRawInvoice_free"))) TS_SignedRawInvoice_free(uint64_t this_obj) {
43872         LDKSignedRawInvoice this_obj_conv;
43873         this_obj_conv.inner = untag_ptr(this_obj);
43874         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43876         SignedRawInvoice_free(this_obj_conv);
43877 }
43878
43879 jboolean  __attribute__((export_name("TS_SignedRawInvoice_eq"))) TS_SignedRawInvoice_eq(uint64_t a, uint64_t b) {
43880         LDKSignedRawInvoice a_conv;
43881         a_conv.inner = untag_ptr(a);
43882         a_conv.is_owned = ptr_is_owned(a);
43883         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43884         a_conv.is_owned = false;
43885         LDKSignedRawInvoice b_conv;
43886         b_conv.inner = untag_ptr(b);
43887         b_conv.is_owned = ptr_is_owned(b);
43888         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43889         b_conv.is_owned = false;
43890         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
43891         return ret_conv;
43892 }
43893
43894 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
43895         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
43896         uint64_t ret_ref = 0;
43897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43899         return ret_ref;
43900 }
43901 int64_t  __attribute__((export_name("TS_SignedRawInvoice_clone_ptr"))) TS_SignedRawInvoice_clone_ptr(uint64_t arg) {
43902         LDKSignedRawInvoice arg_conv;
43903         arg_conv.inner = untag_ptr(arg);
43904         arg_conv.is_owned = ptr_is_owned(arg);
43905         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43906         arg_conv.is_owned = false;
43907         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
43908         return ret_conv;
43909 }
43910
43911 uint64_t  __attribute__((export_name("TS_SignedRawInvoice_clone"))) TS_SignedRawInvoice_clone(uint64_t orig) {
43912         LDKSignedRawInvoice orig_conv;
43913         orig_conv.inner = untag_ptr(orig);
43914         orig_conv.is_owned = ptr_is_owned(orig);
43915         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43916         orig_conv.is_owned = false;
43917         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
43918         uint64_t ret_ref = 0;
43919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43920         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43921         return ret_ref;
43922 }
43923
43924 int64_t  __attribute__((export_name("TS_SignedRawInvoice_hash"))) TS_SignedRawInvoice_hash(uint64_t o) {
43925         LDKSignedRawInvoice o_conv;
43926         o_conv.inner = untag_ptr(o);
43927         o_conv.is_owned = ptr_is_owned(o);
43928         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43929         o_conv.is_owned = false;
43930         int64_t ret_conv = SignedRawInvoice_hash(&o_conv);
43931         return ret_conv;
43932 }
43933
43934 void  __attribute__((export_name("TS_RawInvoice_free"))) TS_RawInvoice_free(uint64_t this_obj) {
43935         LDKRawInvoice this_obj_conv;
43936         this_obj_conv.inner = untag_ptr(this_obj);
43937         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43939         RawInvoice_free(this_obj_conv);
43940 }
43941
43942 uint64_t  __attribute__((export_name("TS_RawInvoice_get_data"))) TS_RawInvoice_get_data(uint64_t this_ptr) {
43943         LDKRawInvoice this_ptr_conv;
43944         this_ptr_conv.inner = untag_ptr(this_ptr);
43945         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43947         this_ptr_conv.is_owned = false;
43948         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
43949         uint64_t ret_ref = 0;
43950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43951         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43952         return ret_ref;
43953 }
43954
43955 void  __attribute__((export_name("TS_RawInvoice_set_data"))) TS_RawInvoice_set_data(uint64_t this_ptr, uint64_t val) {
43956         LDKRawInvoice this_ptr_conv;
43957         this_ptr_conv.inner = untag_ptr(this_ptr);
43958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43960         this_ptr_conv.is_owned = false;
43961         LDKRawDataPart val_conv;
43962         val_conv.inner = untag_ptr(val);
43963         val_conv.is_owned = ptr_is_owned(val);
43964         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43965         val_conv = RawDataPart_clone(&val_conv);
43966         RawInvoice_set_data(&this_ptr_conv, val_conv);
43967 }
43968
43969 jboolean  __attribute__((export_name("TS_RawInvoice_eq"))) TS_RawInvoice_eq(uint64_t a, uint64_t b) {
43970         LDKRawInvoice a_conv;
43971         a_conv.inner = untag_ptr(a);
43972         a_conv.is_owned = ptr_is_owned(a);
43973         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43974         a_conv.is_owned = false;
43975         LDKRawInvoice b_conv;
43976         b_conv.inner = untag_ptr(b);
43977         b_conv.is_owned = ptr_is_owned(b);
43978         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43979         b_conv.is_owned = false;
43980         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
43981         return ret_conv;
43982 }
43983
43984 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
43985         LDKRawInvoice ret_var = RawInvoice_clone(arg);
43986         uint64_t ret_ref = 0;
43987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43989         return ret_ref;
43990 }
43991 int64_t  __attribute__((export_name("TS_RawInvoice_clone_ptr"))) TS_RawInvoice_clone_ptr(uint64_t arg) {
43992         LDKRawInvoice arg_conv;
43993         arg_conv.inner = untag_ptr(arg);
43994         arg_conv.is_owned = ptr_is_owned(arg);
43995         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43996         arg_conv.is_owned = false;
43997         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
43998         return ret_conv;
43999 }
44000
44001 uint64_t  __attribute__((export_name("TS_RawInvoice_clone"))) TS_RawInvoice_clone(uint64_t orig) {
44002         LDKRawInvoice orig_conv;
44003         orig_conv.inner = untag_ptr(orig);
44004         orig_conv.is_owned = ptr_is_owned(orig);
44005         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44006         orig_conv.is_owned = false;
44007         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
44008         uint64_t ret_ref = 0;
44009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44010         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44011         return ret_ref;
44012 }
44013
44014 int64_t  __attribute__((export_name("TS_RawInvoice_hash"))) TS_RawInvoice_hash(uint64_t o) {
44015         LDKRawInvoice o_conv;
44016         o_conv.inner = untag_ptr(o);
44017         o_conv.is_owned = ptr_is_owned(o);
44018         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44019         o_conv.is_owned = false;
44020         int64_t ret_conv = RawInvoice_hash(&o_conv);
44021         return ret_conv;
44022 }
44023
44024 void  __attribute__((export_name("TS_RawDataPart_free"))) TS_RawDataPart_free(uint64_t this_obj) {
44025         LDKRawDataPart this_obj_conv;
44026         this_obj_conv.inner = untag_ptr(this_obj);
44027         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44029         RawDataPart_free(this_obj_conv);
44030 }
44031
44032 uint64_t  __attribute__((export_name("TS_RawDataPart_get_timestamp"))) TS_RawDataPart_get_timestamp(uint64_t this_ptr) {
44033         LDKRawDataPart this_ptr_conv;
44034         this_ptr_conv.inner = untag_ptr(this_ptr);
44035         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44037         this_ptr_conv.is_owned = false;
44038         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
44039         uint64_t ret_ref = 0;
44040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44041         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44042         return ret_ref;
44043 }
44044
44045 void  __attribute__((export_name("TS_RawDataPart_set_timestamp"))) TS_RawDataPart_set_timestamp(uint64_t this_ptr, uint64_t val) {
44046         LDKRawDataPart this_ptr_conv;
44047         this_ptr_conv.inner = untag_ptr(this_ptr);
44048         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44050         this_ptr_conv.is_owned = false;
44051         LDKPositiveTimestamp val_conv;
44052         val_conv.inner = untag_ptr(val);
44053         val_conv.is_owned = ptr_is_owned(val);
44054         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44055         val_conv = PositiveTimestamp_clone(&val_conv);
44056         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
44057 }
44058
44059 jboolean  __attribute__((export_name("TS_RawDataPart_eq"))) TS_RawDataPart_eq(uint64_t a, uint64_t b) {
44060         LDKRawDataPart a_conv;
44061         a_conv.inner = untag_ptr(a);
44062         a_conv.is_owned = ptr_is_owned(a);
44063         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44064         a_conv.is_owned = false;
44065         LDKRawDataPart b_conv;
44066         b_conv.inner = untag_ptr(b);
44067         b_conv.is_owned = ptr_is_owned(b);
44068         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44069         b_conv.is_owned = false;
44070         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
44071         return ret_conv;
44072 }
44073
44074 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
44075         LDKRawDataPart ret_var = RawDataPart_clone(arg);
44076         uint64_t ret_ref = 0;
44077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44078         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44079         return ret_ref;
44080 }
44081 int64_t  __attribute__((export_name("TS_RawDataPart_clone_ptr"))) TS_RawDataPart_clone_ptr(uint64_t arg) {
44082         LDKRawDataPart arg_conv;
44083         arg_conv.inner = untag_ptr(arg);
44084         arg_conv.is_owned = ptr_is_owned(arg);
44085         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44086         arg_conv.is_owned = false;
44087         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
44088         return ret_conv;
44089 }
44090
44091 uint64_t  __attribute__((export_name("TS_RawDataPart_clone"))) TS_RawDataPart_clone(uint64_t orig) {
44092         LDKRawDataPart orig_conv;
44093         orig_conv.inner = untag_ptr(orig);
44094         orig_conv.is_owned = ptr_is_owned(orig);
44095         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44096         orig_conv.is_owned = false;
44097         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
44098         uint64_t ret_ref = 0;
44099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44100         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44101         return ret_ref;
44102 }
44103
44104 int64_t  __attribute__((export_name("TS_RawDataPart_hash"))) TS_RawDataPart_hash(uint64_t o) {
44105         LDKRawDataPart o_conv;
44106         o_conv.inner = untag_ptr(o);
44107         o_conv.is_owned = ptr_is_owned(o);
44108         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44109         o_conv.is_owned = false;
44110         int64_t ret_conv = RawDataPart_hash(&o_conv);
44111         return ret_conv;
44112 }
44113
44114 void  __attribute__((export_name("TS_PositiveTimestamp_free"))) TS_PositiveTimestamp_free(uint64_t this_obj) {
44115         LDKPositiveTimestamp this_obj_conv;
44116         this_obj_conv.inner = untag_ptr(this_obj);
44117         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44119         PositiveTimestamp_free(this_obj_conv);
44120 }
44121
44122 jboolean  __attribute__((export_name("TS_PositiveTimestamp_eq"))) TS_PositiveTimestamp_eq(uint64_t a, uint64_t b) {
44123         LDKPositiveTimestamp a_conv;
44124         a_conv.inner = untag_ptr(a);
44125         a_conv.is_owned = ptr_is_owned(a);
44126         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44127         a_conv.is_owned = false;
44128         LDKPositiveTimestamp b_conv;
44129         b_conv.inner = untag_ptr(b);
44130         b_conv.is_owned = ptr_is_owned(b);
44131         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44132         b_conv.is_owned = false;
44133         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
44134         return ret_conv;
44135 }
44136
44137 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
44138         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
44139         uint64_t ret_ref = 0;
44140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44141         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44142         return ret_ref;
44143 }
44144 int64_t  __attribute__((export_name("TS_PositiveTimestamp_clone_ptr"))) TS_PositiveTimestamp_clone_ptr(uint64_t arg) {
44145         LDKPositiveTimestamp arg_conv;
44146         arg_conv.inner = untag_ptr(arg);
44147         arg_conv.is_owned = ptr_is_owned(arg);
44148         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44149         arg_conv.is_owned = false;
44150         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
44151         return ret_conv;
44152 }
44153
44154 uint64_t  __attribute__((export_name("TS_PositiveTimestamp_clone"))) TS_PositiveTimestamp_clone(uint64_t orig) {
44155         LDKPositiveTimestamp orig_conv;
44156         orig_conv.inner = untag_ptr(orig);
44157         orig_conv.is_owned = ptr_is_owned(orig);
44158         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44159         orig_conv.is_owned = false;
44160         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
44161         uint64_t ret_ref = 0;
44162         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44163         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44164         return ret_ref;
44165 }
44166
44167 int64_t  __attribute__((export_name("TS_PositiveTimestamp_hash"))) TS_PositiveTimestamp_hash(uint64_t o) {
44168         LDKPositiveTimestamp o_conv;
44169         o_conv.inner = untag_ptr(o);
44170         o_conv.is_owned = ptr_is_owned(o);
44171         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44172         o_conv.is_owned = false;
44173         int64_t ret_conv = PositiveTimestamp_hash(&o_conv);
44174         return ret_conv;
44175 }
44176
44177 uint32_t  __attribute__((export_name("TS_SiPrefix_clone"))) TS_SiPrefix_clone(uint64_t orig) {
44178         LDKSiPrefix* orig_conv = (LDKSiPrefix*)untag_ptr(orig);
44179         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
44180         return ret_conv;
44181 }
44182
44183 uint32_t  __attribute__((export_name("TS_SiPrefix_milli"))) TS_SiPrefix_milli() {
44184         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
44185         return ret_conv;
44186 }
44187
44188 uint32_t  __attribute__((export_name("TS_SiPrefix_micro"))) TS_SiPrefix_micro() {
44189         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
44190         return ret_conv;
44191 }
44192
44193 uint32_t  __attribute__((export_name("TS_SiPrefix_nano"))) TS_SiPrefix_nano() {
44194         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
44195         return ret_conv;
44196 }
44197
44198 uint32_t  __attribute__((export_name("TS_SiPrefix_pico"))) TS_SiPrefix_pico() {
44199         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
44200         return ret_conv;
44201 }
44202
44203 jboolean  __attribute__((export_name("TS_SiPrefix_eq"))) TS_SiPrefix_eq(uint64_t a, uint64_t b) {
44204         LDKSiPrefix* a_conv = (LDKSiPrefix*)untag_ptr(a);
44205         LDKSiPrefix* b_conv = (LDKSiPrefix*)untag_ptr(b);
44206         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
44207         return ret_conv;
44208 }
44209
44210 int64_t  __attribute__((export_name("TS_SiPrefix_hash"))) TS_SiPrefix_hash(uint64_t o) {
44211         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
44212         int64_t ret_conv = SiPrefix_hash(o_conv);
44213         return ret_conv;
44214 }
44215
44216 int64_t  __attribute__((export_name("TS_SiPrefix_multiplier"))) TS_SiPrefix_multiplier(uint64_t this_arg) {
44217         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)untag_ptr(this_arg);
44218         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
44219         return ret_conv;
44220 }
44221
44222 uint32_t  __attribute__((export_name("TS_Currency_clone"))) TS_Currency_clone(uint64_t orig) {
44223         LDKCurrency* orig_conv = (LDKCurrency*)untag_ptr(orig);
44224         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
44225         return ret_conv;
44226 }
44227
44228 uint32_t  __attribute__((export_name("TS_Currency_bitcoin"))) TS_Currency_bitcoin() {
44229         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
44230         return ret_conv;
44231 }
44232
44233 uint32_t  __attribute__((export_name("TS_Currency_bitcoin_testnet"))) TS_Currency_bitcoin_testnet() {
44234         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
44235         return ret_conv;
44236 }
44237
44238 uint32_t  __attribute__((export_name("TS_Currency_regtest"))) TS_Currency_regtest() {
44239         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
44240         return ret_conv;
44241 }
44242
44243 uint32_t  __attribute__((export_name("TS_Currency_simnet"))) TS_Currency_simnet() {
44244         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
44245         return ret_conv;
44246 }
44247
44248 uint32_t  __attribute__((export_name("TS_Currency_signet"))) TS_Currency_signet() {
44249         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
44250         return ret_conv;
44251 }
44252
44253 int64_t  __attribute__((export_name("TS_Currency_hash"))) TS_Currency_hash(uint64_t o) {
44254         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
44255         int64_t ret_conv = Currency_hash(o_conv);
44256         return ret_conv;
44257 }
44258
44259 jboolean  __attribute__((export_name("TS_Currency_eq"))) TS_Currency_eq(uint64_t a, uint64_t b) {
44260         LDKCurrency* a_conv = (LDKCurrency*)untag_ptr(a);
44261         LDKCurrency* b_conv = (LDKCurrency*)untag_ptr(b);
44262         jboolean ret_conv = Currency_eq(a_conv, b_conv);
44263         return ret_conv;
44264 }
44265
44266 void  __attribute__((export_name("TS_Sha256_free"))) TS_Sha256_free(uint64_t this_obj) {
44267         LDKSha256 this_obj_conv;
44268         this_obj_conv.inner = untag_ptr(this_obj);
44269         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44271         Sha256_free(this_obj_conv);
44272 }
44273
44274 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
44275         LDKSha256 ret_var = Sha256_clone(arg);
44276         uint64_t ret_ref = 0;
44277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44278         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44279         return ret_ref;
44280 }
44281 int64_t  __attribute__((export_name("TS_Sha256_clone_ptr"))) TS_Sha256_clone_ptr(uint64_t arg) {
44282         LDKSha256 arg_conv;
44283         arg_conv.inner = untag_ptr(arg);
44284         arg_conv.is_owned = ptr_is_owned(arg);
44285         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44286         arg_conv.is_owned = false;
44287         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
44288         return ret_conv;
44289 }
44290
44291 uint64_t  __attribute__((export_name("TS_Sha256_clone"))) TS_Sha256_clone(uint64_t orig) {
44292         LDKSha256 orig_conv;
44293         orig_conv.inner = untag_ptr(orig);
44294         orig_conv.is_owned = ptr_is_owned(orig);
44295         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44296         orig_conv.is_owned = false;
44297         LDKSha256 ret_var = Sha256_clone(&orig_conv);
44298         uint64_t ret_ref = 0;
44299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44300         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44301         return ret_ref;
44302 }
44303
44304 int64_t  __attribute__((export_name("TS_Sha256_hash"))) TS_Sha256_hash(uint64_t o) {
44305         LDKSha256 o_conv;
44306         o_conv.inner = untag_ptr(o);
44307         o_conv.is_owned = ptr_is_owned(o);
44308         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44309         o_conv.is_owned = false;
44310         int64_t ret_conv = Sha256_hash(&o_conv);
44311         return ret_conv;
44312 }
44313
44314 jboolean  __attribute__((export_name("TS_Sha256_eq"))) TS_Sha256_eq(uint64_t a, uint64_t b) {
44315         LDKSha256 a_conv;
44316         a_conv.inner = untag_ptr(a);
44317         a_conv.is_owned = ptr_is_owned(a);
44318         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44319         a_conv.is_owned = false;
44320         LDKSha256 b_conv;
44321         b_conv.inner = untag_ptr(b);
44322         b_conv.is_owned = ptr_is_owned(b);
44323         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44324         b_conv.is_owned = false;
44325         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
44326         return ret_conv;
44327 }
44328
44329 void  __attribute__((export_name("TS_Description_free"))) TS_Description_free(uint64_t this_obj) {
44330         LDKDescription this_obj_conv;
44331         this_obj_conv.inner = untag_ptr(this_obj);
44332         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44334         Description_free(this_obj_conv);
44335 }
44336
44337 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
44338         LDKDescription ret_var = Description_clone(arg);
44339         uint64_t ret_ref = 0;
44340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44341         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44342         return ret_ref;
44343 }
44344 int64_t  __attribute__((export_name("TS_Description_clone_ptr"))) TS_Description_clone_ptr(uint64_t arg) {
44345         LDKDescription arg_conv;
44346         arg_conv.inner = untag_ptr(arg);
44347         arg_conv.is_owned = ptr_is_owned(arg);
44348         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44349         arg_conv.is_owned = false;
44350         int64_t ret_conv = Description_clone_ptr(&arg_conv);
44351         return ret_conv;
44352 }
44353
44354 uint64_t  __attribute__((export_name("TS_Description_clone"))) TS_Description_clone(uint64_t orig) {
44355         LDKDescription orig_conv;
44356         orig_conv.inner = untag_ptr(orig);
44357         orig_conv.is_owned = ptr_is_owned(orig);
44358         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44359         orig_conv.is_owned = false;
44360         LDKDescription ret_var = Description_clone(&orig_conv);
44361         uint64_t ret_ref = 0;
44362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44363         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44364         return ret_ref;
44365 }
44366
44367 int64_t  __attribute__((export_name("TS_Description_hash"))) TS_Description_hash(uint64_t o) {
44368         LDKDescription o_conv;
44369         o_conv.inner = untag_ptr(o);
44370         o_conv.is_owned = ptr_is_owned(o);
44371         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44372         o_conv.is_owned = false;
44373         int64_t ret_conv = Description_hash(&o_conv);
44374         return ret_conv;
44375 }
44376
44377 jboolean  __attribute__((export_name("TS_Description_eq"))) TS_Description_eq(uint64_t a, uint64_t b) {
44378         LDKDescription a_conv;
44379         a_conv.inner = untag_ptr(a);
44380         a_conv.is_owned = ptr_is_owned(a);
44381         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44382         a_conv.is_owned = false;
44383         LDKDescription b_conv;
44384         b_conv.inner = untag_ptr(b);
44385         b_conv.is_owned = ptr_is_owned(b);
44386         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44387         b_conv.is_owned = false;
44388         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
44389         return ret_conv;
44390 }
44391
44392 void  __attribute__((export_name("TS_PayeePubKey_free"))) TS_PayeePubKey_free(uint64_t this_obj) {
44393         LDKPayeePubKey this_obj_conv;
44394         this_obj_conv.inner = untag_ptr(this_obj);
44395         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44397         PayeePubKey_free(this_obj_conv);
44398 }
44399
44400 int8_tArray  __attribute__((export_name("TS_PayeePubKey_get_a"))) TS_PayeePubKey_get_a(uint64_t this_ptr) {
44401         LDKPayeePubKey this_ptr_conv;
44402         this_ptr_conv.inner = untag_ptr(this_ptr);
44403         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44405         this_ptr_conv.is_owned = false;
44406         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
44407         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
44408         return ret_arr;
44409 }
44410
44411 void  __attribute__((export_name("TS_PayeePubKey_set_a"))) TS_PayeePubKey_set_a(uint64_t this_ptr, int8_tArray val) {
44412         LDKPayeePubKey this_ptr_conv;
44413         this_ptr_conv.inner = untag_ptr(this_ptr);
44414         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44416         this_ptr_conv.is_owned = false;
44417         LDKPublicKey val_ref;
44418         CHECK(val->arr_len == 33);
44419         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
44420         PayeePubKey_set_a(&this_ptr_conv, val_ref);
44421 }
44422
44423 uint64_t  __attribute__((export_name("TS_PayeePubKey_new"))) TS_PayeePubKey_new(int8_tArray a_arg) {
44424         LDKPublicKey a_arg_ref;
44425         CHECK(a_arg->arr_len == 33);
44426         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
44427         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
44428         uint64_t ret_ref = 0;
44429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44430         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44431         return ret_ref;
44432 }
44433
44434 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
44435         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
44436         uint64_t ret_ref = 0;
44437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44438         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44439         return ret_ref;
44440 }
44441 int64_t  __attribute__((export_name("TS_PayeePubKey_clone_ptr"))) TS_PayeePubKey_clone_ptr(uint64_t arg) {
44442         LDKPayeePubKey arg_conv;
44443         arg_conv.inner = untag_ptr(arg);
44444         arg_conv.is_owned = ptr_is_owned(arg);
44445         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44446         arg_conv.is_owned = false;
44447         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
44448         return ret_conv;
44449 }
44450
44451 uint64_t  __attribute__((export_name("TS_PayeePubKey_clone"))) TS_PayeePubKey_clone(uint64_t orig) {
44452         LDKPayeePubKey orig_conv;
44453         orig_conv.inner = untag_ptr(orig);
44454         orig_conv.is_owned = ptr_is_owned(orig);
44455         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44456         orig_conv.is_owned = false;
44457         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
44458         uint64_t ret_ref = 0;
44459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44460         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44461         return ret_ref;
44462 }
44463
44464 int64_t  __attribute__((export_name("TS_PayeePubKey_hash"))) TS_PayeePubKey_hash(uint64_t o) {
44465         LDKPayeePubKey o_conv;
44466         o_conv.inner = untag_ptr(o);
44467         o_conv.is_owned = ptr_is_owned(o);
44468         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44469         o_conv.is_owned = false;
44470         int64_t ret_conv = PayeePubKey_hash(&o_conv);
44471         return ret_conv;
44472 }
44473
44474 jboolean  __attribute__((export_name("TS_PayeePubKey_eq"))) TS_PayeePubKey_eq(uint64_t a, uint64_t b) {
44475         LDKPayeePubKey a_conv;
44476         a_conv.inner = untag_ptr(a);
44477         a_conv.is_owned = ptr_is_owned(a);
44478         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44479         a_conv.is_owned = false;
44480         LDKPayeePubKey b_conv;
44481         b_conv.inner = untag_ptr(b);
44482         b_conv.is_owned = ptr_is_owned(b);
44483         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44484         b_conv.is_owned = false;
44485         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
44486         return ret_conv;
44487 }
44488
44489 void  __attribute__((export_name("TS_ExpiryTime_free"))) TS_ExpiryTime_free(uint64_t this_obj) {
44490         LDKExpiryTime this_obj_conv;
44491         this_obj_conv.inner = untag_ptr(this_obj);
44492         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44494         ExpiryTime_free(this_obj_conv);
44495 }
44496
44497 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
44498         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
44499         uint64_t ret_ref = 0;
44500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44501         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44502         return ret_ref;
44503 }
44504 int64_t  __attribute__((export_name("TS_ExpiryTime_clone_ptr"))) TS_ExpiryTime_clone_ptr(uint64_t arg) {
44505         LDKExpiryTime arg_conv;
44506         arg_conv.inner = untag_ptr(arg);
44507         arg_conv.is_owned = ptr_is_owned(arg);
44508         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44509         arg_conv.is_owned = false;
44510         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
44511         return ret_conv;
44512 }
44513
44514 uint64_t  __attribute__((export_name("TS_ExpiryTime_clone"))) TS_ExpiryTime_clone(uint64_t orig) {
44515         LDKExpiryTime orig_conv;
44516         orig_conv.inner = untag_ptr(orig);
44517         orig_conv.is_owned = ptr_is_owned(orig);
44518         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44519         orig_conv.is_owned = false;
44520         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
44521         uint64_t ret_ref = 0;
44522         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44523         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44524         return ret_ref;
44525 }
44526
44527 int64_t  __attribute__((export_name("TS_ExpiryTime_hash"))) TS_ExpiryTime_hash(uint64_t o) {
44528         LDKExpiryTime o_conv;
44529         o_conv.inner = untag_ptr(o);
44530         o_conv.is_owned = ptr_is_owned(o);
44531         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44532         o_conv.is_owned = false;
44533         int64_t ret_conv = ExpiryTime_hash(&o_conv);
44534         return ret_conv;
44535 }
44536
44537 jboolean  __attribute__((export_name("TS_ExpiryTime_eq"))) TS_ExpiryTime_eq(uint64_t a, uint64_t b) {
44538         LDKExpiryTime a_conv;
44539         a_conv.inner = untag_ptr(a);
44540         a_conv.is_owned = ptr_is_owned(a);
44541         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44542         a_conv.is_owned = false;
44543         LDKExpiryTime b_conv;
44544         b_conv.inner = untag_ptr(b);
44545         b_conv.is_owned = ptr_is_owned(b);
44546         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44547         b_conv.is_owned = false;
44548         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
44549         return ret_conv;
44550 }
44551
44552 void  __attribute__((export_name("TS_MinFinalCltvExpiry_free"))) TS_MinFinalCltvExpiry_free(uint64_t this_obj) {
44553         LDKMinFinalCltvExpiry this_obj_conv;
44554         this_obj_conv.inner = untag_ptr(this_obj);
44555         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44557         MinFinalCltvExpiry_free(this_obj_conv);
44558 }
44559
44560 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_get_a"))) TS_MinFinalCltvExpiry_get_a(uint64_t this_ptr) {
44561         LDKMinFinalCltvExpiry this_ptr_conv;
44562         this_ptr_conv.inner = untag_ptr(this_ptr);
44563         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44565         this_ptr_conv.is_owned = false;
44566         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
44567         return ret_conv;
44568 }
44569
44570 void  __attribute__((export_name("TS_MinFinalCltvExpiry_set_a"))) TS_MinFinalCltvExpiry_set_a(uint64_t this_ptr, int64_t val) {
44571         LDKMinFinalCltvExpiry this_ptr_conv;
44572         this_ptr_conv.inner = untag_ptr(this_ptr);
44573         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44575         this_ptr_conv.is_owned = false;
44576         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
44577 }
44578
44579 uint64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_new"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
44580         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
44581         uint64_t ret_ref = 0;
44582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44583         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44584         return ret_ref;
44585 }
44586
44587 static inline uint64_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
44588         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
44589         uint64_t ret_ref = 0;
44590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44591         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44592         return ret_ref;
44593 }
44594 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone_ptr"))) TS_MinFinalCltvExpiry_clone_ptr(uint64_t arg) {
44595         LDKMinFinalCltvExpiry arg_conv;
44596         arg_conv.inner = untag_ptr(arg);
44597         arg_conv.is_owned = ptr_is_owned(arg);
44598         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44599         arg_conv.is_owned = false;
44600         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
44601         return ret_conv;
44602 }
44603
44604 uint64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone"))) TS_MinFinalCltvExpiry_clone(uint64_t orig) {
44605         LDKMinFinalCltvExpiry orig_conv;
44606         orig_conv.inner = untag_ptr(orig);
44607         orig_conv.is_owned = ptr_is_owned(orig);
44608         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44609         orig_conv.is_owned = false;
44610         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
44611         uint64_t ret_ref = 0;
44612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44613         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44614         return ret_ref;
44615 }
44616
44617 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_hash"))) TS_MinFinalCltvExpiry_hash(uint64_t o) {
44618         LDKMinFinalCltvExpiry o_conv;
44619         o_conv.inner = untag_ptr(o);
44620         o_conv.is_owned = ptr_is_owned(o);
44621         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44622         o_conv.is_owned = false;
44623         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
44624         return ret_conv;
44625 }
44626
44627 jboolean  __attribute__((export_name("TS_MinFinalCltvExpiry_eq"))) TS_MinFinalCltvExpiry_eq(uint64_t a, uint64_t b) {
44628         LDKMinFinalCltvExpiry a_conv;
44629         a_conv.inner = untag_ptr(a);
44630         a_conv.is_owned = ptr_is_owned(a);
44631         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44632         a_conv.is_owned = false;
44633         LDKMinFinalCltvExpiry b_conv;
44634         b_conv.inner = untag_ptr(b);
44635         b_conv.is_owned = ptr_is_owned(b);
44636         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44637         b_conv.is_owned = false;
44638         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
44639         return ret_conv;
44640 }
44641
44642 void  __attribute__((export_name("TS_Fallback_free"))) TS_Fallback_free(uint64_t this_ptr) {
44643         if (!ptr_is_owned(this_ptr)) return;
44644         void* this_ptr_ptr = untag_ptr(this_ptr);
44645         CHECK_ACCESS(this_ptr_ptr);
44646         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
44647         FREE(untag_ptr(this_ptr));
44648         Fallback_free(this_ptr_conv);
44649 }
44650
44651 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
44652         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44653         *ret_copy = Fallback_clone(arg);
44654         uint64_t ret_ref = tag_ptr(ret_copy, true);
44655         return ret_ref;
44656 }
44657 int64_t  __attribute__((export_name("TS_Fallback_clone_ptr"))) TS_Fallback_clone_ptr(uint64_t arg) {
44658         LDKFallback* arg_conv = (LDKFallback*)untag_ptr(arg);
44659         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
44660         return ret_conv;
44661 }
44662
44663 uint64_t  __attribute__((export_name("TS_Fallback_clone"))) TS_Fallback_clone(uint64_t orig) {
44664         LDKFallback* orig_conv = (LDKFallback*)untag_ptr(orig);
44665         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44666         *ret_copy = Fallback_clone(orig_conv);
44667         uint64_t ret_ref = tag_ptr(ret_copy, true);
44668         return ret_ref;
44669 }
44670
44671 uint64_t  __attribute__((export_name("TS_Fallback_seg_wit_program"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
44672         
44673         LDKCVec_u8Z program_ref;
44674         program_ref.datalen = program->arr_len;
44675         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
44676         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
44677         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44678         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
44679         uint64_t ret_ref = tag_ptr(ret_copy, true);
44680         return ret_ref;
44681 }
44682
44683 uint64_t  __attribute__((export_name("TS_Fallback_pub_key_hash"))) TS_Fallback_pub_key_hash(int8_tArray a) {
44684         LDKTwentyBytes a_ref;
44685         CHECK(a->arr_len == 20);
44686         memcpy(a_ref.data, a->elems, 20); FREE(a);
44687         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44688         *ret_copy = Fallback_pub_key_hash(a_ref);
44689         uint64_t ret_ref = tag_ptr(ret_copy, true);
44690         return ret_ref;
44691 }
44692
44693 uint64_t  __attribute__((export_name("TS_Fallback_script_hash"))) TS_Fallback_script_hash(int8_tArray a) {
44694         LDKTwentyBytes a_ref;
44695         CHECK(a->arr_len == 20);
44696         memcpy(a_ref.data, a->elems, 20); FREE(a);
44697         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44698         *ret_copy = Fallback_script_hash(a_ref);
44699         uint64_t ret_ref = tag_ptr(ret_copy, true);
44700         return ret_ref;
44701 }
44702
44703 int64_t  __attribute__((export_name("TS_Fallback_hash"))) TS_Fallback_hash(uint64_t o) {
44704         LDKFallback* o_conv = (LDKFallback*)untag_ptr(o);
44705         int64_t ret_conv = Fallback_hash(o_conv);
44706         return ret_conv;
44707 }
44708
44709 jboolean  __attribute__((export_name("TS_Fallback_eq"))) TS_Fallback_eq(uint64_t a, uint64_t b) {
44710         LDKFallback* a_conv = (LDKFallback*)untag_ptr(a);
44711         LDKFallback* b_conv = (LDKFallback*)untag_ptr(b);
44712         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
44713         return ret_conv;
44714 }
44715
44716 void  __attribute__((export_name("TS_InvoiceSignature_free"))) TS_InvoiceSignature_free(uint64_t this_obj) {
44717         LDKInvoiceSignature this_obj_conv;
44718         this_obj_conv.inner = untag_ptr(this_obj);
44719         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44721         InvoiceSignature_free(this_obj_conv);
44722 }
44723
44724 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
44725         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
44726         uint64_t ret_ref = 0;
44727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44728         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44729         return ret_ref;
44730 }
44731 int64_t  __attribute__((export_name("TS_InvoiceSignature_clone_ptr"))) TS_InvoiceSignature_clone_ptr(uint64_t arg) {
44732         LDKInvoiceSignature arg_conv;
44733         arg_conv.inner = untag_ptr(arg);
44734         arg_conv.is_owned = ptr_is_owned(arg);
44735         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44736         arg_conv.is_owned = false;
44737         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
44738         return ret_conv;
44739 }
44740
44741 uint64_t  __attribute__((export_name("TS_InvoiceSignature_clone"))) TS_InvoiceSignature_clone(uint64_t orig) {
44742         LDKInvoiceSignature orig_conv;
44743         orig_conv.inner = untag_ptr(orig);
44744         orig_conv.is_owned = ptr_is_owned(orig);
44745         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44746         orig_conv.is_owned = false;
44747         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
44748         uint64_t ret_ref = 0;
44749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44750         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44751         return ret_ref;
44752 }
44753
44754 int64_t  __attribute__((export_name("TS_InvoiceSignature_hash"))) TS_InvoiceSignature_hash(uint64_t o) {
44755         LDKInvoiceSignature o_conv;
44756         o_conv.inner = untag_ptr(o);
44757         o_conv.is_owned = ptr_is_owned(o);
44758         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44759         o_conv.is_owned = false;
44760         int64_t ret_conv = InvoiceSignature_hash(&o_conv);
44761         return ret_conv;
44762 }
44763
44764 jboolean  __attribute__((export_name("TS_InvoiceSignature_eq"))) TS_InvoiceSignature_eq(uint64_t a, uint64_t b) {
44765         LDKInvoiceSignature a_conv;
44766         a_conv.inner = untag_ptr(a);
44767         a_conv.is_owned = ptr_is_owned(a);
44768         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44769         a_conv.is_owned = false;
44770         LDKInvoiceSignature b_conv;
44771         b_conv.inner = untag_ptr(b);
44772         b_conv.is_owned = ptr_is_owned(b);
44773         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44774         b_conv.is_owned = false;
44775         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
44776         return ret_conv;
44777 }
44778
44779 void  __attribute__((export_name("TS_PrivateRoute_free"))) TS_PrivateRoute_free(uint64_t this_obj) {
44780         LDKPrivateRoute this_obj_conv;
44781         this_obj_conv.inner = untag_ptr(this_obj);
44782         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44784         PrivateRoute_free(this_obj_conv);
44785 }
44786
44787 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
44788         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
44789         uint64_t ret_ref = 0;
44790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44791         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44792         return ret_ref;
44793 }
44794 int64_t  __attribute__((export_name("TS_PrivateRoute_clone_ptr"))) TS_PrivateRoute_clone_ptr(uint64_t arg) {
44795         LDKPrivateRoute arg_conv;
44796         arg_conv.inner = untag_ptr(arg);
44797         arg_conv.is_owned = ptr_is_owned(arg);
44798         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44799         arg_conv.is_owned = false;
44800         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
44801         return ret_conv;
44802 }
44803
44804 uint64_t  __attribute__((export_name("TS_PrivateRoute_clone"))) TS_PrivateRoute_clone(uint64_t orig) {
44805         LDKPrivateRoute orig_conv;
44806         orig_conv.inner = untag_ptr(orig);
44807         orig_conv.is_owned = ptr_is_owned(orig);
44808         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44809         orig_conv.is_owned = false;
44810         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
44811         uint64_t ret_ref = 0;
44812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44813         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44814         return ret_ref;
44815 }
44816
44817 int64_t  __attribute__((export_name("TS_PrivateRoute_hash"))) TS_PrivateRoute_hash(uint64_t o) {
44818         LDKPrivateRoute o_conv;
44819         o_conv.inner = untag_ptr(o);
44820         o_conv.is_owned = ptr_is_owned(o);
44821         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44822         o_conv.is_owned = false;
44823         int64_t ret_conv = PrivateRoute_hash(&o_conv);
44824         return ret_conv;
44825 }
44826
44827 jboolean  __attribute__((export_name("TS_PrivateRoute_eq"))) TS_PrivateRoute_eq(uint64_t a, uint64_t b) {
44828         LDKPrivateRoute a_conv;
44829         a_conv.inner = untag_ptr(a);
44830         a_conv.is_owned = ptr_is_owned(a);
44831         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44832         a_conv.is_owned = false;
44833         LDKPrivateRoute b_conv;
44834         b_conv.inner = untag_ptr(b);
44835         b_conv.is_owned = ptr_is_owned(b);
44836         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44837         b_conv.is_owned = false;
44838         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
44839         return ret_conv;
44840 }
44841
44842 uint64_t  __attribute__((export_name("TS_SignedRawInvoice_into_parts"))) TS_SignedRawInvoice_into_parts(uint64_t this_arg) {
44843         LDKSignedRawInvoice this_arg_conv;
44844         this_arg_conv.inner = untag_ptr(this_arg);
44845         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44847         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
44848         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
44849         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
44850         return tag_ptr(ret_conv, true);
44851 }
44852
44853 uint64_t  __attribute__((export_name("TS_SignedRawInvoice_raw_invoice"))) TS_SignedRawInvoice_raw_invoice(uint64_t this_arg) {
44854         LDKSignedRawInvoice this_arg_conv;
44855         this_arg_conv.inner = untag_ptr(this_arg);
44856         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44858         this_arg_conv.is_owned = false;
44859         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
44860         uint64_t ret_ref = 0;
44861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44862         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44863         return ret_ref;
44864 }
44865
44866 int8_tArray  __attribute__((export_name("TS_SignedRawInvoice_signable_hash"))) TS_SignedRawInvoice_signable_hash(uint64_t this_arg) {
44867         LDKSignedRawInvoice this_arg_conv;
44868         this_arg_conv.inner = untag_ptr(this_arg);
44869         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44871         this_arg_conv.is_owned = false;
44872         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44873         memcpy(ret_arr->elems, *SignedRawInvoice_signable_hash(&this_arg_conv), 32);
44874         return ret_arr;
44875 }
44876
44877 uint64_t  __attribute__((export_name("TS_SignedRawInvoice_signature"))) TS_SignedRawInvoice_signature(uint64_t this_arg) {
44878         LDKSignedRawInvoice this_arg_conv;
44879         this_arg_conv.inner = untag_ptr(this_arg);
44880         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44882         this_arg_conv.is_owned = false;
44883         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
44884         uint64_t ret_ref = 0;
44885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44886         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44887         return ret_ref;
44888 }
44889
44890 uint64_t  __attribute__((export_name("TS_SignedRawInvoice_recover_payee_pub_key"))) TS_SignedRawInvoice_recover_payee_pub_key(uint64_t this_arg) {
44891         LDKSignedRawInvoice this_arg_conv;
44892         this_arg_conv.inner = untag_ptr(this_arg);
44893         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44895         this_arg_conv.is_owned = false;
44896         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
44897         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
44898         return tag_ptr(ret_conv, true);
44899 }
44900
44901 jboolean  __attribute__((export_name("TS_SignedRawInvoice_check_signature"))) TS_SignedRawInvoice_check_signature(uint64_t this_arg) {
44902         LDKSignedRawInvoice this_arg_conv;
44903         this_arg_conv.inner = untag_ptr(this_arg);
44904         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44906         this_arg_conv.is_owned = false;
44907         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
44908         return ret_conv;
44909 }
44910
44911 int8_tArray  __attribute__((export_name("TS_RawInvoice_signable_hash"))) TS_RawInvoice_signable_hash(uint64_t this_arg) {
44912         LDKRawInvoice this_arg_conv;
44913         this_arg_conv.inner = untag_ptr(this_arg);
44914         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44916         this_arg_conv.is_owned = false;
44917         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44918         memcpy(ret_arr->elems, RawInvoice_signable_hash(&this_arg_conv).data, 32);
44919         return ret_arr;
44920 }
44921
44922 uint64_t  __attribute__((export_name("TS_RawInvoice_payment_hash"))) TS_RawInvoice_payment_hash(uint64_t this_arg) {
44923         LDKRawInvoice this_arg_conv;
44924         this_arg_conv.inner = untag_ptr(this_arg);
44925         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44927         this_arg_conv.is_owned = false;
44928         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
44929         uint64_t ret_ref = 0;
44930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44931         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44932         return ret_ref;
44933 }
44934
44935 uint64_t  __attribute__((export_name("TS_RawInvoice_description"))) TS_RawInvoice_description(uint64_t this_arg) {
44936         LDKRawInvoice this_arg_conv;
44937         this_arg_conv.inner = untag_ptr(this_arg);
44938         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44940         this_arg_conv.is_owned = false;
44941         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
44942         uint64_t ret_ref = 0;
44943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44944         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44945         return ret_ref;
44946 }
44947
44948 uint64_t  __attribute__((export_name("TS_RawInvoice_payee_pub_key"))) TS_RawInvoice_payee_pub_key(uint64_t this_arg) {
44949         LDKRawInvoice this_arg_conv;
44950         this_arg_conv.inner = untag_ptr(this_arg);
44951         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44953         this_arg_conv.is_owned = false;
44954         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
44955         uint64_t ret_ref = 0;
44956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44957         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44958         return ret_ref;
44959 }
44960
44961 uint64_t  __attribute__((export_name("TS_RawInvoice_description_hash"))) TS_RawInvoice_description_hash(uint64_t this_arg) {
44962         LDKRawInvoice this_arg_conv;
44963         this_arg_conv.inner = untag_ptr(this_arg);
44964         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44966         this_arg_conv.is_owned = false;
44967         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
44968         uint64_t ret_ref = 0;
44969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44970         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44971         return ret_ref;
44972 }
44973
44974 uint64_t  __attribute__((export_name("TS_RawInvoice_expiry_time"))) TS_RawInvoice_expiry_time(uint64_t this_arg) {
44975         LDKRawInvoice this_arg_conv;
44976         this_arg_conv.inner = untag_ptr(this_arg);
44977         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44979         this_arg_conv.is_owned = false;
44980         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
44981         uint64_t ret_ref = 0;
44982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44983         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44984         return ret_ref;
44985 }
44986
44987 uint64_t  __attribute__((export_name("TS_RawInvoice_min_final_cltv_expiry"))) TS_RawInvoice_min_final_cltv_expiry(uint64_t this_arg) {
44988         LDKRawInvoice this_arg_conv;
44989         this_arg_conv.inner = untag_ptr(this_arg);
44990         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44992         this_arg_conv.is_owned = false;
44993         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
44994         uint64_t ret_ref = 0;
44995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44996         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44997         return ret_ref;
44998 }
44999
45000 int8_tArray  __attribute__((export_name("TS_RawInvoice_payment_secret"))) TS_RawInvoice_payment_secret(uint64_t this_arg) {
45001         LDKRawInvoice this_arg_conv;
45002         this_arg_conv.inner = untag_ptr(this_arg);
45003         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45005         this_arg_conv.is_owned = false;
45006         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
45007         memcpy(ret_arr->elems, RawInvoice_payment_secret(&this_arg_conv).data, 32);
45008         return ret_arr;
45009 }
45010
45011 uint64_t  __attribute__((export_name("TS_RawInvoice_features"))) TS_RawInvoice_features(uint64_t this_arg) {
45012         LDKRawInvoice this_arg_conv;
45013         this_arg_conv.inner = untag_ptr(this_arg);
45014         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45016         this_arg_conv.is_owned = false;
45017         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
45018         uint64_t ret_ref = 0;
45019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45020         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45021         return ret_ref;
45022 }
45023
45024 uint64_tArray  __attribute__((export_name("TS_RawInvoice_private_routes"))) TS_RawInvoice_private_routes(uint64_t this_arg) {
45025         LDKRawInvoice this_arg_conv;
45026         this_arg_conv.inner = untag_ptr(this_arg);
45027         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45029         this_arg_conv.is_owned = false;
45030         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
45031         uint64_tArray ret_arr = NULL;
45032         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
45033         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
45034         for (size_t o = 0; o < ret_var.datalen; o++) {
45035                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
45036                 uint64_t ret_conv_14_ref = 0;
45037                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
45038                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
45039                 ret_arr_ptr[o] = ret_conv_14_ref;
45040         }
45041         
45042         FREE(ret_var.data);
45043         return ret_arr;
45044 }
45045
45046 uint64_t  __attribute__((export_name("TS_RawInvoice_amount_pico_btc"))) TS_RawInvoice_amount_pico_btc(uint64_t this_arg) {
45047         LDKRawInvoice this_arg_conv;
45048         this_arg_conv.inner = untag_ptr(this_arg);
45049         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45051         this_arg_conv.is_owned = false;
45052         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45053         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
45054         uint64_t ret_ref = tag_ptr(ret_copy, true);
45055         return ret_ref;
45056 }
45057
45058 uint32_t  __attribute__((export_name("TS_RawInvoice_currency"))) TS_RawInvoice_currency(uint64_t this_arg) {
45059         LDKRawInvoice this_arg_conv;
45060         this_arg_conv.inner = untag_ptr(this_arg);
45061         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45063         this_arg_conv.is_owned = false;
45064         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
45065         return ret_conv;
45066 }
45067
45068 uint64_t  __attribute__((export_name("TS_PositiveTimestamp_from_unix_timestamp"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
45069         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45070         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
45071         return tag_ptr(ret_conv, true);
45072 }
45073
45074 uint64_t  __attribute__((export_name("TS_PositiveTimestamp_from_duration_since_epoch"))) TS_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
45075         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45076         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
45077         return tag_ptr(ret_conv, true);
45078 }
45079
45080 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_unix_timestamp"))) TS_PositiveTimestamp_as_unix_timestamp(uint64_t this_arg) {
45081         LDKPositiveTimestamp this_arg_conv;
45082         this_arg_conv.inner = untag_ptr(this_arg);
45083         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45085         this_arg_conv.is_owned = false;
45086         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
45087         return ret_conv;
45088 }
45089
45090 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_duration_since_epoch"))) TS_PositiveTimestamp_as_duration_since_epoch(uint64_t this_arg) {
45091         LDKPositiveTimestamp this_arg_conv;
45092         this_arg_conv.inner = untag_ptr(this_arg);
45093         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45095         this_arg_conv.is_owned = false;
45096         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
45097         return ret_conv;
45098 }
45099
45100 uint64_t  __attribute__((export_name("TS_Invoice_into_signed_raw"))) TS_Invoice_into_signed_raw(uint64_t this_arg) {
45101         LDKInvoice this_arg_conv;
45102         this_arg_conv.inner = untag_ptr(this_arg);
45103         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45105         this_arg_conv = Invoice_clone(&this_arg_conv);
45106         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
45107         uint64_t ret_ref = 0;
45108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45109         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45110         return ret_ref;
45111 }
45112
45113 uint64_t  __attribute__((export_name("TS_Invoice_check_signature"))) TS_Invoice_check_signature(uint64_t this_arg) {
45114         LDKInvoice this_arg_conv;
45115         this_arg_conv.inner = untag_ptr(this_arg);
45116         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45118         this_arg_conv.is_owned = false;
45119         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
45120         *ret_conv = Invoice_check_signature(&this_arg_conv);
45121         return tag_ptr(ret_conv, true);
45122 }
45123
45124 uint64_t  __attribute__((export_name("TS_Invoice_from_signed"))) TS_Invoice_from_signed(uint64_t signed_invoice) {
45125         LDKSignedRawInvoice signed_invoice_conv;
45126         signed_invoice_conv.inner = untag_ptr(signed_invoice);
45127         signed_invoice_conv.is_owned = ptr_is_owned(signed_invoice);
45128         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
45129         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
45130         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
45131         *ret_conv = Invoice_from_signed(signed_invoice_conv);
45132         return tag_ptr(ret_conv, true);
45133 }
45134
45135 int64_t  __attribute__((export_name("TS_Invoice_duration_since_epoch"))) TS_Invoice_duration_since_epoch(uint64_t this_arg) {
45136         LDKInvoice this_arg_conv;
45137         this_arg_conv.inner = untag_ptr(this_arg);
45138         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45140         this_arg_conv.is_owned = false;
45141         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
45142         return ret_conv;
45143 }
45144
45145 int8_tArray  __attribute__((export_name("TS_Invoice_payment_hash"))) TS_Invoice_payment_hash(uint64_t this_arg) {
45146         LDKInvoice this_arg_conv;
45147         this_arg_conv.inner = untag_ptr(this_arg);
45148         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45150         this_arg_conv.is_owned = false;
45151         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
45152         memcpy(ret_arr->elems, *Invoice_payment_hash(&this_arg_conv), 32);
45153         return ret_arr;
45154 }
45155
45156 int8_tArray  __attribute__((export_name("TS_Invoice_payee_pub_key"))) TS_Invoice_payee_pub_key(uint64_t this_arg) {
45157         LDKInvoice this_arg_conv;
45158         this_arg_conv.inner = untag_ptr(this_arg);
45159         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45161         this_arg_conv.is_owned = false;
45162         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
45163         memcpy(ret_arr->elems, Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
45164         return ret_arr;
45165 }
45166
45167 int8_tArray  __attribute__((export_name("TS_Invoice_payment_secret"))) TS_Invoice_payment_secret(uint64_t this_arg) {
45168         LDKInvoice this_arg_conv;
45169         this_arg_conv.inner = untag_ptr(this_arg);
45170         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45172         this_arg_conv.is_owned = false;
45173         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
45174         memcpy(ret_arr->elems, *Invoice_payment_secret(&this_arg_conv), 32);
45175         return ret_arr;
45176 }
45177
45178 uint64_t  __attribute__((export_name("TS_Invoice_features"))) TS_Invoice_features(uint64_t this_arg) {
45179         LDKInvoice this_arg_conv;
45180         this_arg_conv.inner = untag_ptr(this_arg);
45181         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45183         this_arg_conv.is_owned = false;
45184         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
45185         uint64_t ret_ref = 0;
45186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45187         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45188         return ret_ref;
45189 }
45190
45191 int8_tArray  __attribute__((export_name("TS_Invoice_recover_payee_pub_key"))) TS_Invoice_recover_payee_pub_key(uint64_t this_arg) {
45192         LDKInvoice this_arg_conv;
45193         this_arg_conv.inner = untag_ptr(this_arg);
45194         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45196         this_arg_conv.is_owned = false;
45197         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
45198         memcpy(ret_arr->elems, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
45199         return ret_arr;
45200 }
45201
45202 int64_t  __attribute__((export_name("TS_Invoice_expiry_time"))) TS_Invoice_expiry_time(uint64_t this_arg) {
45203         LDKInvoice this_arg_conv;
45204         this_arg_conv.inner = untag_ptr(this_arg);
45205         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45207         this_arg_conv.is_owned = false;
45208         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
45209         return ret_conv;
45210 }
45211
45212 jboolean  __attribute__((export_name("TS_Invoice_would_expire"))) TS_Invoice_would_expire(uint64_t this_arg, int64_t at_time) {
45213         LDKInvoice this_arg_conv;
45214         this_arg_conv.inner = untag_ptr(this_arg);
45215         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45217         this_arg_conv.is_owned = false;
45218         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
45219         return ret_conv;
45220 }
45221
45222 int64_t  __attribute__((export_name("TS_Invoice_min_final_cltv_expiry"))) TS_Invoice_min_final_cltv_expiry(uint64_t this_arg) {
45223         LDKInvoice this_arg_conv;
45224         this_arg_conv.inner = untag_ptr(this_arg);
45225         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45227         this_arg_conv.is_owned = false;
45228         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
45229         return ret_conv;
45230 }
45231
45232 uint64_tArray  __attribute__((export_name("TS_Invoice_private_routes"))) TS_Invoice_private_routes(uint64_t this_arg) {
45233         LDKInvoice this_arg_conv;
45234         this_arg_conv.inner = untag_ptr(this_arg);
45235         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45237         this_arg_conv.is_owned = false;
45238         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
45239         uint64_tArray ret_arr = NULL;
45240         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
45241         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
45242         for (size_t o = 0; o < ret_var.datalen; o++) {
45243                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
45244                 uint64_t ret_conv_14_ref = 0;
45245                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
45246                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
45247                 ret_arr_ptr[o] = ret_conv_14_ref;
45248         }
45249         
45250         FREE(ret_var.data);
45251         return ret_arr;
45252 }
45253
45254 uint64_tArray  __attribute__((export_name("TS_Invoice_route_hints"))) TS_Invoice_route_hints(uint64_t this_arg) {
45255         LDKInvoice this_arg_conv;
45256         this_arg_conv.inner = untag_ptr(this_arg);
45257         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45259         this_arg_conv.is_owned = false;
45260         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
45261         uint64_tArray ret_arr = NULL;
45262         ret_arr = init_uint64_tArray(ret_var.datalen, __LINE__);
45263         uint64_t *ret_arr_ptr = (uint64_t*)(((uint8_t*)ret_arr) + 8);
45264         for (size_t l = 0; l < ret_var.datalen; l++) {
45265                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
45266                 uint64_t ret_conv_11_ref = 0;
45267                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
45268                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
45269                 ret_arr_ptr[l] = ret_conv_11_ref;
45270         }
45271         
45272         FREE(ret_var.data);
45273         return ret_arr;
45274 }
45275
45276 uint32_t  __attribute__((export_name("TS_Invoice_currency"))) TS_Invoice_currency(uint64_t this_arg) {
45277         LDKInvoice this_arg_conv;
45278         this_arg_conv.inner = untag_ptr(this_arg);
45279         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45281         this_arg_conv.is_owned = false;
45282         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
45283         return ret_conv;
45284 }
45285
45286 uint64_t  __attribute__((export_name("TS_Invoice_amount_milli_satoshis"))) TS_Invoice_amount_milli_satoshis(uint64_t this_arg) {
45287         LDKInvoice this_arg_conv;
45288         this_arg_conv.inner = untag_ptr(this_arg);
45289         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45291         this_arg_conv.is_owned = false;
45292         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45293         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
45294         uint64_t ret_ref = tag_ptr(ret_copy, true);
45295         return ret_ref;
45296 }
45297
45298 uint64_t  __attribute__((export_name("TS_Description_new"))) TS_Description_new(jstring description) {
45299         LDKStr description_conv = str_ref_to_owned_c(description);
45300         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
45301         *ret_conv = Description_new(description_conv);
45302         return tag_ptr(ret_conv, true);
45303 }
45304
45305 jstring  __attribute__((export_name("TS_Description_into_inner"))) TS_Description_into_inner(uint64_t this_arg) {
45306         LDKDescription this_arg_conv;
45307         this_arg_conv.inner = untag_ptr(this_arg);
45308         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45310         this_arg_conv = Description_clone(&this_arg_conv);
45311         LDKStr ret_str = Description_into_inner(this_arg_conv);
45312         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45313         Str_free(ret_str);
45314         return ret_conv;
45315 }
45316
45317 uint64_t  __attribute__((export_name("TS_ExpiryTime_from_seconds"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
45318         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
45319         uint64_t ret_ref = 0;
45320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45321         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45322         return ret_ref;
45323 }
45324
45325 uint64_t  __attribute__((export_name("TS_ExpiryTime_from_duration"))) TS_ExpiryTime_from_duration(int64_t duration) {
45326         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
45327         uint64_t ret_ref = 0;
45328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45329         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45330         return ret_ref;
45331 }
45332
45333 int64_t  __attribute__((export_name("TS_ExpiryTime_as_seconds"))) TS_ExpiryTime_as_seconds(uint64_t this_arg) {
45334         LDKExpiryTime this_arg_conv;
45335         this_arg_conv.inner = untag_ptr(this_arg);
45336         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45338         this_arg_conv.is_owned = false;
45339         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
45340         return ret_conv;
45341 }
45342
45343 int64_t  __attribute__((export_name("TS_ExpiryTime_as_duration"))) TS_ExpiryTime_as_duration(uint64_t this_arg) {
45344         LDKExpiryTime this_arg_conv;
45345         this_arg_conv.inner = untag_ptr(this_arg);
45346         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45348         this_arg_conv.is_owned = false;
45349         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
45350         return ret_conv;
45351 }
45352
45353 uint64_t  __attribute__((export_name("TS_PrivateRoute_new"))) TS_PrivateRoute_new(uint64_t hops) {
45354         LDKRouteHint hops_conv;
45355         hops_conv.inner = untag_ptr(hops);
45356         hops_conv.is_owned = ptr_is_owned(hops);
45357         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
45358         hops_conv = RouteHint_clone(&hops_conv);
45359         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
45360         *ret_conv = PrivateRoute_new(hops_conv);
45361         return tag_ptr(ret_conv, true);
45362 }
45363
45364 uint64_t  __attribute__((export_name("TS_PrivateRoute_into_inner"))) TS_PrivateRoute_into_inner(uint64_t this_arg) {
45365         LDKPrivateRoute this_arg_conv;
45366         this_arg_conv.inner = untag_ptr(this_arg);
45367         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45369         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
45370         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
45371         uint64_t ret_ref = 0;
45372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45373         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45374         return ret_ref;
45375 }
45376
45377 uint32_t  __attribute__((export_name("TS_CreationError_clone"))) TS_CreationError_clone(uint64_t orig) {
45378         LDKCreationError* orig_conv = (LDKCreationError*)untag_ptr(orig);
45379         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
45380         return ret_conv;
45381 }
45382
45383 uint32_t  __attribute__((export_name("TS_CreationError_description_too_long"))) TS_CreationError_description_too_long() {
45384         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
45385         return ret_conv;
45386 }
45387
45388 uint32_t  __attribute__((export_name("TS_CreationError_route_too_long"))) TS_CreationError_route_too_long() {
45389         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
45390         return ret_conv;
45391 }
45392
45393 uint32_t  __attribute__((export_name("TS_CreationError_timestamp_out_of_bounds"))) TS_CreationError_timestamp_out_of_bounds() {
45394         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
45395         return ret_conv;
45396 }
45397
45398 uint32_t  __attribute__((export_name("TS_CreationError_invalid_amount"))) TS_CreationError_invalid_amount() {
45399         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
45400         return ret_conv;
45401 }
45402
45403 uint32_t  __attribute__((export_name("TS_CreationError_missing_route_hints"))) TS_CreationError_missing_route_hints() {
45404         uint32_t ret_conv = LDKCreationError_to_js(CreationError_missing_route_hints());
45405         return ret_conv;
45406 }
45407
45408 jboolean  __attribute__((export_name("TS_CreationError_eq"))) TS_CreationError_eq(uint64_t a, uint64_t b) {
45409         LDKCreationError* a_conv = (LDKCreationError*)untag_ptr(a);
45410         LDKCreationError* b_conv = (LDKCreationError*)untag_ptr(b);
45411         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
45412         return ret_conv;
45413 }
45414
45415 jstring  __attribute__((export_name("TS_CreationError_to_str"))) TS_CreationError_to_str(uint64_t o) {
45416         LDKCreationError* o_conv = (LDKCreationError*)untag_ptr(o);
45417         LDKStr ret_str = CreationError_to_str(o_conv);
45418         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45419         Str_free(ret_str);
45420         return ret_conv;
45421 }
45422
45423 uint32_t  __attribute__((export_name("TS_SemanticError_clone"))) TS_SemanticError_clone(uint64_t orig) {
45424         LDKSemanticError* orig_conv = (LDKSemanticError*)untag_ptr(orig);
45425         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
45426         return ret_conv;
45427 }
45428
45429 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_hash"))) TS_SemanticError_no_payment_hash() {
45430         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
45431         return ret_conv;
45432 }
45433
45434 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_hashes"))) TS_SemanticError_multiple_payment_hashes() {
45435         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
45436         return ret_conv;
45437 }
45438
45439 uint32_t  __attribute__((export_name("TS_SemanticError_no_description"))) TS_SemanticError_no_description() {
45440         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
45441         return ret_conv;
45442 }
45443
45444 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_descriptions"))) TS_SemanticError_multiple_descriptions() {
45445         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
45446         return ret_conv;
45447 }
45448
45449 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_secret"))) TS_SemanticError_no_payment_secret() {
45450         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
45451         return ret_conv;
45452 }
45453
45454 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_secrets"))) TS_SemanticError_multiple_payment_secrets() {
45455         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
45456         return ret_conv;
45457 }
45458
45459 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_features"))) TS_SemanticError_invalid_features() {
45460         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
45461         return ret_conv;
45462 }
45463
45464 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_recovery_id"))) TS_SemanticError_invalid_recovery_id() {
45465         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
45466         return ret_conv;
45467 }
45468
45469 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_signature"))) TS_SemanticError_invalid_signature() {
45470         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
45471         return ret_conv;
45472 }
45473
45474 uint32_t  __attribute__((export_name("TS_SemanticError_imprecise_amount"))) TS_SemanticError_imprecise_amount() {
45475         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
45476         return ret_conv;
45477 }
45478
45479 jboolean  __attribute__((export_name("TS_SemanticError_eq"))) TS_SemanticError_eq(uint64_t a, uint64_t b) {
45480         LDKSemanticError* a_conv = (LDKSemanticError*)untag_ptr(a);
45481         LDKSemanticError* b_conv = (LDKSemanticError*)untag_ptr(b);
45482         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
45483         return ret_conv;
45484 }
45485
45486 jstring  __attribute__((export_name("TS_SemanticError_to_str"))) TS_SemanticError_to_str(uint64_t o) {
45487         LDKSemanticError* o_conv = (LDKSemanticError*)untag_ptr(o);
45488         LDKStr ret_str = SemanticError_to_str(o_conv);
45489         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45490         Str_free(ret_str);
45491         return ret_conv;
45492 }
45493
45494 void  __attribute__((export_name("TS_SignOrCreationError_free"))) TS_SignOrCreationError_free(uint64_t this_ptr) {
45495         if (!ptr_is_owned(this_ptr)) return;
45496         void* this_ptr_ptr = untag_ptr(this_ptr);
45497         CHECK_ACCESS(this_ptr_ptr);
45498         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
45499         FREE(untag_ptr(this_ptr));
45500         SignOrCreationError_free(this_ptr_conv);
45501 }
45502
45503 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
45504         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45505         *ret_copy = SignOrCreationError_clone(arg);
45506         uint64_t ret_ref = tag_ptr(ret_copy, true);
45507         return ret_ref;
45508 }
45509 int64_t  __attribute__((export_name("TS_SignOrCreationError_clone_ptr"))) TS_SignOrCreationError_clone_ptr(uint64_t arg) {
45510         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)untag_ptr(arg);
45511         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
45512         return ret_conv;
45513 }
45514
45515 uint64_t  __attribute__((export_name("TS_SignOrCreationError_clone"))) TS_SignOrCreationError_clone(uint64_t orig) {
45516         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)untag_ptr(orig);
45517         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45518         *ret_copy = SignOrCreationError_clone(orig_conv);
45519         uint64_t ret_ref = tag_ptr(ret_copy, true);
45520         return ret_ref;
45521 }
45522
45523 uint64_t  __attribute__((export_name("TS_SignOrCreationError_sign_error"))) TS_SignOrCreationError_sign_error() {
45524         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45525         *ret_copy = SignOrCreationError_sign_error();
45526         uint64_t ret_ref = tag_ptr(ret_copy, true);
45527         return ret_ref;
45528 }
45529
45530 uint64_t  __attribute__((export_name("TS_SignOrCreationError_creation_error"))) TS_SignOrCreationError_creation_error(uint32_t a) {
45531         LDKCreationError a_conv = LDKCreationError_from_js(a);
45532         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45533         *ret_copy = SignOrCreationError_creation_error(a_conv);
45534         uint64_t ret_ref = tag_ptr(ret_copy, true);
45535         return ret_ref;
45536 }
45537
45538 jboolean  __attribute__((export_name("TS_SignOrCreationError_eq"))) TS_SignOrCreationError_eq(uint64_t a, uint64_t b) {
45539         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)untag_ptr(a);
45540         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)untag_ptr(b);
45541         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
45542         return ret_conv;
45543 }
45544
45545 jstring  __attribute__((export_name("TS_SignOrCreationError_to_str"))) TS_SignOrCreationError_to_str(uint64_t o) {
45546         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)untag_ptr(o);
45547         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
45548         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45549         Str_free(ret_str);
45550         return ret_conv;
45551 }
45552
45553 void  __attribute__((export_name("TS_InvoicePayer_free"))) TS_InvoicePayer_free(uint64_t this_obj) {
45554         LDKInvoicePayer this_obj_conv;
45555         this_obj_conv.inner = untag_ptr(this_obj);
45556         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45558         InvoicePayer_free(this_obj_conv);
45559 }
45560
45561 void  __attribute__((export_name("TS_Payer_free"))) TS_Payer_free(uint64_t this_ptr) {
45562         if (!ptr_is_owned(this_ptr)) return;
45563         void* this_ptr_ptr = untag_ptr(this_ptr);
45564         CHECK_ACCESS(this_ptr_ptr);
45565         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
45566         FREE(untag_ptr(this_ptr));
45567         Payer_free(this_ptr_conv);
45568 }
45569
45570 void  __attribute__((export_name("TS_Router_free"))) TS_Router_free(uint64_t this_ptr) {
45571         if (!ptr_is_owned(this_ptr)) return;
45572         void* this_ptr_ptr = untag_ptr(this_ptr);
45573         CHECK_ACCESS(this_ptr_ptr);
45574         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
45575         FREE(untag_ptr(this_ptr));
45576         Router_free(this_ptr_conv);
45577 }
45578
45579 void  __attribute__((export_name("TS_Retry_free"))) TS_Retry_free(uint64_t this_ptr) {
45580         if (!ptr_is_owned(this_ptr)) return;
45581         void* this_ptr_ptr = untag_ptr(this_ptr);
45582         CHECK_ACCESS(this_ptr_ptr);
45583         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
45584         FREE(untag_ptr(this_ptr));
45585         Retry_free(this_ptr_conv);
45586 }
45587
45588 static inline uint64_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
45589         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
45590         *ret_copy = Retry_clone(arg);
45591         uint64_t ret_ref = tag_ptr(ret_copy, true);
45592         return ret_ref;
45593 }
45594 int64_t  __attribute__((export_name("TS_Retry_clone_ptr"))) TS_Retry_clone_ptr(uint64_t arg) {
45595         LDKRetry* arg_conv = (LDKRetry*)untag_ptr(arg);
45596         int64_t ret_conv = Retry_clone_ptr(arg_conv);
45597         return ret_conv;
45598 }
45599
45600 uint64_t  __attribute__((export_name("TS_Retry_clone"))) TS_Retry_clone(uint64_t orig) {
45601         LDKRetry* orig_conv = (LDKRetry*)untag_ptr(orig);
45602         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
45603         *ret_copy = Retry_clone(orig_conv);
45604         uint64_t ret_ref = tag_ptr(ret_copy, true);
45605         return ret_ref;
45606 }
45607
45608 uint64_t  __attribute__((export_name("TS_Retry_attempts"))) TS_Retry_attempts(uint32_t a) {
45609         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
45610         *ret_copy = Retry_attempts(a);
45611         uint64_t ret_ref = tag_ptr(ret_copy, true);
45612         return ret_ref;
45613 }
45614
45615 jboolean  __attribute__((export_name("TS_Retry_eq"))) TS_Retry_eq(uint64_t a, uint64_t b) {
45616         LDKRetry* a_conv = (LDKRetry*)untag_ptr(a);
45617         LDKRetry* b_conv = (LDKRetry*)untag_ptr(b);
45618         jboolean ret_conv = Retry_eq(a_conv, b_conv);
45619         return ret_conv;
45620 }
45621
45622 int64_t  __attribute__((export_name("TS_Retry_hash"))) TS_Retry_hash(uint64_t o) {
45623         LDKRetry* o_conv = (LDKRetry*)untag_ptr(o);
45624         int64_t ret_conv = Retry_hash(o_conv);
45625         return ret_conv;
45626 }
45627
45628 void  __attribute__((export_name("TS_PaymentError_free"))) TS_PaymentError_free(uint64_t this_ptr) {
45629         if (!ptr_is_owned(this_ptr)) return;
45630         void* this_ptr_ptr = untag_ptr(this_ptr);
45631         CHECK_ACCESS(this_ptr_ptr);
45632         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
45633         FREE(untag_ptr(this_ptr));
45634         PaymentError_free(this_ptr_conv);
45635 }
45636
45637 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
45638         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45639         *ret_copy = PaymentError_clone(arg);
45640         uint64_t ret_ref = tag_ptr(ret_copy, true);
45641         return ret_ref;
45642 }
45643 int64_t  __attribute__((export_name("TS_PaymentError_clone_ptr"))) TS_PaymentError_clone_ptr(uint64_t arg) {
45644         LDKPaymentError* arg_conv = (LDKPaymentError*)untag_ptr(arg);
45645         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
45646         return ret_conv;
45647 }
45648
45649 uint64_t  __attribute__((export_name("TS_PaymentError_clone"))) TS_PaymentError_clone(uint64_t orig) {
45650         LDKPaymentError* orig_conv = (LDKPaymentError*)untag_ptr(orig);
45651         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45652         *ret_copy = PaymentError_clone(orig_conv);
45653         uint64_t ret_ref = tag_ptr(ret_copy, true);
45654         return ret_ref;
45655 }
45656
45657 uint64_t  __attribute__((export_name("TS_PaymentError_invoice"))) TS_PaymentError_invoice(jstring a) {
45658         LDKStr a_conv = str_ref_to_owned_c(a);
45659         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45660         *ret_copy = PaymentError_invoice(a_conv);
45661         uint64_t ret_ref = tag_ptr(ret_copy, true);
45662         return ret_ref;
45663 }
45664
45665 uint64_t  __attribute__((export_name("TS_PaymentError_routing"))) TS_PaymentError_routing(uint64_t a) {
45666         LDKLightningError a_conv;
45667         a_conv.inner = untag_ptr(a);
45668         a_conv.is_owned = ptr_is_owned(a);
45669         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45670         a_conv = LightningError_clone(&a_conv);
45671         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45672         *ret_copy = PaymentError_routing(a_conv);
45673         uint64_t ret_ref = tag_ptr(ret_copy, true);
45674         return ret_ref;
45675 }
45676
45677 uint64_t  __attribute__((export_name("TS_PaymentError_sending"))) TS_PaymentError_sending(uint64_t a) {
45678         void* a_ptr = untag_ptr(a);
45679         CHECK_ACCESS(a_ptr);
45680         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
45681         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(a));
45682         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45683         *ret_copy = PaymentError_sending(a_conv);
45684         uint64_t ret_ref = tag_ptr(ret_copy, true);
45685         return ret_ref;
45686 }
45687
45688 uint64_t  __attribute__((export_name("TS_InvoicePayer_new"))) TS_InvoicePayer_new(uint64_t payer, uint64_t router, uint64_t logger, uint64_t event_handler, uint64_t retry) {
45689         void* payer_ptr = untag_ptr(payer);
45690         CHECK_ACCESS(payer_ptr);
45691         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
45692         if (payer_conv.free == LDKPayer_JCalls_free) {
45693                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45694                 LDKPayer_JCalls_cloned(&payer_conv);
45695         }
45696         void* router_ptr = untag_ptr(router);
45697         CHECK_ACCESS(router_ptr);
45698         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
45699         if (router_conv.free == LDKRouter_JCalls_free) {
45700                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45701                 LDKRouter_JCalls_cloned(&router_conv);
45702         }
45703         void* logger_ptr = untag_ptr(logger);
45704         CHECK_ACCESS(logger_ptr);
45705         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45706         if (logger_conv.free == LDKLogger_JCalls_free) {
45707                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45708                 LDKLogger_JCalls_cloned(&logger_conv);
45709         }
45710         void* event_handler_ptr = untag_ptr(event_handler);
45711         CHECK_ACCESS(event_handler_ptr);
45712         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
45713         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
45714                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45715                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
45716         }
45717         void* retry_ptr = untag_ptr(retry);
45718         CHECK_ACCESS(retry_ptr);
45719         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
45720         retry_conv = Retry_clone((LDKRetry*)untag_ptr(retry));
45721         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, logger_conv, event_handler_conv, retry_conv);
45722         uint64_t ret_ref = 0;
45723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45724         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45725         return ret_ref;
45726 }
45727
45728 uint64_t  __attribute__((export_name("TS_InvoicePayer_pay_invoice"))) TS_InvoicePayer_pay_invoice(uint64_t this_arg, uint64_t invoice) {
45729         LDKInvoicePayer this_arg_conv;
45730         this_arg_conv.inner = untag_ptr(this_arg);
45731         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45733         this_arg_conv.is_owned = false;
45734         LDKInvoice invoice_conv;
45735         invoice_conv.inner = untag_ptr(invoice);
45736         invoice_conv.is_owned = ptr_is_owned(invoice);
45737         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45738         invoice_conv.is_owned = false;
45739         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45740         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
45741         return tag_ptr(ret_conv, true);
45742 }
45743
45744 uint64_t  __attribute__((export_name("TS_InvoicePayer_pay_zero_value_invoice"))) TS_InvoicePayer_pay_zero_value_invoice(uint64_t this_arg, uint64_t invoice, int64_t amount_msats) {
45745         LDKInvoicePayer this_arg_conv;
45746         this_arg_conv.inner = untag_ptr(this_arg);
45747         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45749         this_arg_conv.is_owned = false;
45750         LDKInvoice invoice_conv;
45751         invoice_conv.inner = untag_ptr(invoice);
45752         invoice_conv.is_owned = ptr_is_owned(invoice);
45753         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45754         invoice_conv.is_owned = false;
45755         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45756         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
45757         return tag_ptr(ret_conv, true);
45758 }
45759
45760 uint64_t  __attribute__((export_name("TS_InvoicePayer_pay_pubkey"))) TS_InvoicePayer_pay_pubkey(uint64_t this_arg, int8_tArray pubkey, int8_tArray payment_preimage, int64_t amount_msats, int32_t final_cltv_expiry_delta) {
45761         LDKInvoicePayer this_arg_conv;
45762         this_arg_conv.inner = untag_ptr(this_arg);
45763         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45765         this_arg_conv.is_owned = false;
45766         LDKPublicKey pubkey_ref;
45767         CHECK(pubkey->arr_len == 33);
45768         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
45769         LDKThirtyTwoBytes payment_preimage_ref;
45770         CHECK(payment_preimage->arr_len == 32);
45771         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
45772         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45773         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
45774         return tag_ptr(ret_conv, true);
45775 }
45776
45777 void  __attribute__((export_name("TS_InvoicePayer_remove_cached_payment"))) TS_InvoicePayer_remove_cached_payment(uint64_t this_arg, int8_tArray payment_hash) {
45778         LDKInvoicePayer this_arg_conv;
45779         this_arg_conv.inner = untag_ptr(this_arg);
45780         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45782         this_arg_conv.is_owned = false;
45783         unsigned char payment_hash_arr[32];
45784         CHECK(payment_hash->arr_len == 32);
45785         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
45786         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
45787         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
45788 }
45789
45790 uint64_t  __attribute__((export_name("TS_InvoicePayer_as_EventHandler"))) TS_InvoicePayer_as_EventHandler(uint64_t this_arg) {
45791         LDKInvoicePayer this_arg_conv;
45792         this_arg_conv.inner = untag_ptr(this_arg);
45793         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45795         this_arg_conv.is_owned = false;
45796         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
45797         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
45798         return tag_ptr(ret_ret, true);
45799 }
45800
45801 void  __attribute__((export_name("TS_InFlightHtlcs_free"))) TS_InFlightHtlcs_free(uint64_t this_obj) {
45802         LDKInFlightHtlcs this_obj_conv;
45803         this_obj_conv.inner = untag_ptr(this_obj);
45804         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45806         InFlightHtlcs_free(this_obj_conv);
45807 }
45808
45809 uint64_t  __attribute__((export_name("TS_InFlightHtlcs_used_liquidity_msat"))) TS_InFlightHtlcs_used_liquidity_msat(uint64_t this_arg, uint64_t source, uint64_t target, int64_t channel_scid) {
45810         LDKInFlightHtlcs this_arg_conv;
45811         this_arg_conv.inner = untag_ptr(this_arg);
45812         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45814         this_arg_conv.is_owned = false;
45815         LDKNodeId source_conv;
45816         source_conv.inner = untag_ptr(source);
45817         source_conv.is_owned = ptr_is_owned(source);
45818         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
45819         source_conv.is_owned = false;
45820         LDKNodeId target_conv;
45821         target_conv.inner = untag_ptr(target);
45822         target_conv.is_owned = ptr_is_owned(target);
45823         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
45824         target_conv.is_owned = false;
45825         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45826         *ret_copy = InFlightHtlcs_used_liquidity_msat(&this_arg_conv, &source_conv, &target_conv, channel_scid);
45827         uint64_t ret_ref = tag_ptr(ret_copy, true);
45828         return ret_ref;
45829 }
45830
45831 int8_tArray  __attribute__((export_name("TS_InFlightHtlcs_write"))) TS_InFlightHtlcs_write(uint64_t obj) {
45832         LDKInFlightHtlcs obj_conv;
45833         obj_conv.inner = untag_ptr(obj);
45834         obj_conv.is_owned = ptr_is_owned(obj);
45835         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45836         obj_conv.is_owned = false;
45837         LDKCVec_u8Z ret_var = InFlightHtlcs_write(&obj_conv);
45838         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
45839         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
45840         CVec_u8Z_free(ret_var);
45841         return ret_arr;
45842 }
45843
45844 uint64_t  __attribute__((export_name("TS_InFlightHtlcs_read"))) TS_InFlightHtlcs_read(int8_tArray ser) {
45845         LDKu8slice ser_ref;
45846         ser_ref.datalen = ser->arr_len;
45847         ser_ref.data = ser->elems;
45848         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
45849         *ret_conv = InFlightHtlcs_read(ser_ref);
45850         FREE(ser);
45851         return tag_ptr(ret_conv, true);
45852 }
45853
45854 uint64_t  __attribute__((export_name("TS_create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch"))) TS_create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(uint64_t channelmanager, uint64_t keys_manager, uint32_t network, uint64_t amt_msat, uint64_t description_hash, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
45855         LDKChannelManager channelmanager_conv;
45856         channelmanager_conv.inner = untag_ptr(channelmanager);
45857         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
45858         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
45859         channelmanager_conv.is_owned = false;
45860         void* keys_manager_ptr = untag_ptr(keys_manager);
45861         CHECK_ACCESS(keys_manager_ptr);
45862         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45863         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45864                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45865                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45866         }
45867         LDKCurrency network_conv = LDKCurrency_from_js(network);
45868         void* amt_msat_ptr = untag_ptr(amt_msat);
45869         CHECK_ACCESS(amt_msat_ptr);
45870         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45871         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
45872         LDKSha256 description_hash_conv;
45873         description_hash_conv.inner = untag_ptr(description_hash);
45874         description_hash_conv.is_owned = ptr_is_owned(description_hash);
45875         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
45876         description_hash_conv = Sha256_clone(&description_hash_conv);
45877         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
45878         *ret_conv = create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv, duration_since_epoch, invoice_expiry_delta_secs);
45879         return tag_ptr(ret_conv, true);
45880 }
45881
45882 uint64_t  __attribute__((export_name("TS_create_invoice_from_channelmanager_and_duration_since_epoch"))) TS_create_invoice_from_channelmanager_and_duration_since_epoch(uint64_t channelmanager, uint64_t keys_manager, uint32_t network, uint64_t amt_msat, jstring description, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
45883         LDKChannelManager channelmanager_conv;
45884         channelmanager_conv.inner = untag_ptr(channelmanager);
45885         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
45886         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
45887         channelmanager_conv.is_owned = false;
45888         void* keys_manager_ptr = untag_ptr(keys_manager);
45889         CHECK_ACCESS(keys_manager_ptr);
45890         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45891         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45892                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45893                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45894         }
45895         LDKCurrency network_conv = LDKCurrency_from_js(network);
45896         void* amt_msat_ptr = untag_ptr(amt_msat);
45897         CHECK_ACCESS(amt_msat_ptr);
45898         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45899         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
45900         LDKStr description_conv = str_ref_to_owned_c(description);
45901         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
45902         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch, invoice_expiry_delta_secs);
45903         return tag_ptr(ret_conv, true);
45904 }
45905
45906 void  __attribute__((export_name("TS_DefaultRouter_free"))) TS_DefaultRouter_free(uint64_t this_obj) {
45907         LDKDefaultRouter this_obj_conv;
45908         this_obj_conv.inner = untag_ptr(this_obj);
45909         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45911         DefaultRouter_free(this_obj_conv);
45912 }
45913
45914 uint64_t  __attribute__((export_name("TS_DefaultRouter_new"))) TS_DefaultRouter_new(uint64_t network_graph, uint64_t logger, int8_tArray random_seed_bytes, uint64_t scorer) {
45915         LDKNetworkGraph network_graph_conv;
45916         network_graph_conv.inner = untag_ptr(network_graph);
45917         network_graph_conv.is_owned = ptr_is_owned(network_graph);
45918         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
45919         network_graph_conv.is_owned = false;
45920         void* logger_ptr = untag_ptr(logger);
45921         CHECK_ACCESS(logger_ptr);
45922         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45923         if (logger_conv.free == LDKLogger_JCalls_free) {
45924                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45925                 LDKLogger_JCalls_cloned(&logger_conv);
45926         }
45927         LDKThirtyTwoBytes random_seed_bytes_ref;
45928         CHECK(random_seed_bytes->arr_len == 32);
45929         memcpy(random_seed_bytes_ref.data, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
45930         void* scorer_ptr = untag_ptr(scorer);
45931         CHECK_ACCESS(scorer_ptr);
45932         LDKLockableScore scorer_conv = *(LDKLockableScore*)(scorer_ptr);
45933         if (scorer_conv.free == LDKLockableScore_JCalls_free) {
45934                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45935                 LDKLockableScore_JCalls_cloned(&scorer_conv);
45936         }
45937         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref, scorer_conv);
45938         uint64_t ret_ref = 0;
45939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45940         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45941         return ret_ref;
45942 }
45943
45944 uint64_t  __attribute__((export_name("TS_DefaultRouter_as_Router"))) TS_DefaultRouter_as_Router(uint64_t this_arg) {
45945         LDKDefaultRouter this_arg_conv;
45946         this_arg_conv.inner = untag_ptr(this_arg);
45947         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45949         this_arg_conv.is_owned = false;
45950         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
45951         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
45952         return tag_ptr(ret_ret, true);
45953 }
45954
45955 uint64_t  __attribute__((export_name("TS_ChannelManager_as_Payer"))) TS_ChannelManager_as_Payer(uint64_t this_arg) {
45956         LDKChannelManager this_arg_conv;
45957         this_arg_conv.inner = untag_ptr(this_arg);
45958         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45960         this_arg_conv.is_owned = false;
45961         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
45962         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
45963         return tag_ptr(ret_ret, true);
45964 }
45965
45966 uint64_t  __attribute__((export_name("TS_SiPrefix_from_str"))) TS_SiPrefix_from_str(jstring s) {
45967         LDKStr s_conv = str_ref_to_owned_c(s);
45968         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
45969         *ret_conv = SiPrefix_from_str(s_conv);
45970         return tag_ptr(ret_conv, true);
45971 }
45972
45973 uint64_t  __attribute__((export_name("TS_Invoice_from_str"))) TS_Invoice_from_str(jstring s) {
45974         LDKStr s_conv = str_ref_to_owned_c(s);
45975         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
45976         *ret_conv = Invoice_from_str(s_conv);
45977         return tag_ptr(ret_conv, true);
45978 }
45979
45980 uint64_t  __attribute__((export_name("TS_SignedRawInvoice_from_str"))) TS_SignedRawInvoice_from_str(jstring s) {
45981         LDKStr s_conv = str_ref_to_owned_c(s);
45982         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
45983         *ret_conv = SignedRawInvoice_from_str(s_conv);
45984         return tag_ptr(ret_conv, true);
45985 }
45986
45987 jstring  __attribute__((export_name("TS_ParseError_to_str"))) TS_ParseError_to_str(uint64_t o) {
45988         LDKParseError* o_conv = (LDKParseError*)untag_ptr(o);
45989         LDKStr ret_str = ParseError_to_str(o_conv);
45990         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45991         Str_free(ret_str);
45992         return ret_conv;
45993 }
45994
45995 jstring  __attribute__((export_name("TS_ParseOrSemanticError_to_str"))) TS_ParseOrSemanticError_to_str(uint64_t o) {
45996         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)untag_ptr(o);
45997         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
45998         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45999         Str_free(ret_str);
46000         return ret_conv;
46001 }
46002
46003 jstring  __attribute__((export_name("TS_Invoice_to_str"))) TS_Invoice_to_str(uint64_t o) {
46004         LDKInvoice o_conv;
46005         o_conv.inner = untag_ptr(o);
46006         o_conv.is_owned = ptr_is_owned(o);
46007         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46008         o_conv.is_owned = false;
46009         LDKStr ret_str = Invoice_to_str(&o_conv);
46010         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
46011         Str_free(ret_str);
46012         return ret_conv;
46013 }
46014
46015 jstring  __attribute__((export_name("TS_SignedRawInvoice_to_str"))) TS_SignedRawInvoice_to_str(uint64_t o) {
46016         LDKSignedRawInvoice o_conv;
46017         o_conv.inner = untag_ptr(o);
46018         o_conv.is_owned = ptr_is_owned(o);
46019         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46020         o_conv.is_owned = false;
46021         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
46022         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
46023         Str_free(ret_str);
46024         return ret_conv;
46025 }
46026
46027 jstring  __attribute__((export_name("TS_Currency_to_str"))) TS_Currency_to_str(uint64_t o) {
46028         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
46029         LDKStr ret_str = Currency_to_str(o_conv);
46030         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
46031         Str_free(ret_str);
46032         return ret_conv;
46033 }
46034
46035 jstring  __attribute__((export_name("TS_SiPrefix_to_str"))) TS_SiPrefix_to_str(uint64_t o) {
46036         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
46037         LDKStr ret_str = SiPrefix_to_str(o_conv);
46038         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
46039         Str_free(ret_str);
46040         return ret_conv;
46041 }
46042